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.

MqttClientAdapterFactory.cs 960 B

преди 7 години
преди 7 години
1234567891011121314151617181920212223242526
  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. }