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.

MqttFactoryExtensions.cs 863 B

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