MqttSubProtocolSelector.cs 513 B

12345678910111213141516
  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. }