您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

27 行
960 B

  1. using System;
  2. using MQTTnet.Adapter;
  3. using MQTTnet.Client;
  4. using MQTTnet.Diagnostics;
  5. using MQTTnet.Serializer;
  6. namespace MQTTnet.Implementations
  7. {
  8. public class MqttClientAdapterFactory : IMqttClientAdapterFactory
  9. {
  10. public IMqttChannelAdapter CreateClientAdapter(IMqttClientChannelOptions options, IMqttNetLogger logger)
  11. {
  12. if (options == null) throw new ArgumentNullException(nameof(options));
  13. switch (options)
  14. {
  15. case MqttClientTcpOptions tcpOptions:
  16. return new MqttChannelAdapter(new MqttTcpChannel(tcpOptions), new MqttPacketSerializer(), logger);
  17. case MqttClientWebSocketOptions webSocketOptions:
  18. return new MqttChannelAdapter(new MqttWebSocketChannel(webSocketOptions), new MqttPacketSerializer(), logger);
  19. default:
  20. throw new NotSupportedException();
  21. }
  22. }
  23. }
  24. }