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

MqttFactoryExtensions.cs 890 B

123456789101112131415161718192021222324
  1. using System;
  2. using MQTTnet.Client;
  3. using MQTTnet.Diagnostics;
  4. namespace MQTTnet.Extensions.ManagedClient
  5. {
  6. public static class MqttFactoryExtensions
  7. {
  8. public static IManagedMqttClient CreateManagedMqttClient(this IMqttClientFactory factory)
  9. {
  10. if (factory == null) throw new ArgumentNullException(nameof(factory));
  11. return new ManagedMqttClient(factory.CreateMqttClient(), new MqttNetLogger().CreateChildLogger());
  12. }
  13. public static IManagedMqttClient CreateManagedMqttClient(this IMqttClientFactory factory, IMqttNetLogger logger)
  14. {
  15. if (factory == null) throw new ArgumentNullException(nameof(factory));
  16. if (logger == null) throw new ArgumentNullException(nameof(logger));
  17. return new ManagedMqttClient(factory.CreateMqttClient(), logger.CreateChildLogger());
  18. }
  19. }
  20. }