You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

17 lines
513 B

  1. using System.Collections.Generic;
  2. using System.Linq;
  3. namespace MQTTnet.AspNetCore
  4. {
  5. public static class MqttSubProtocolSelector
  6. {
  7. public static string SelectSubProtocol(IList<string> requestedSubProtocolValues)
  8. {
  9. // Order the protocols to also match "mqtt", "mqttv-3.1", "mqttv-3.11" etc.
  10. return requestedSubProtocolValues
  11. .OrderByDescending(p => p.Length)
  12. .FirstOrDefault(p => p.ToLower().StartsWith("mqtt"));
  13. }
  14. }
  15. }