Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

MqttClientExtensions.cs 943 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. namespace MQTTnet.Core.Client
  6. {
  7. public static class MqttClientExtensions
  8. {
  9. public static Task<IList<MqttSubscribeResult>> SubscribeAsync(this IMqttClient client, params TopicFilter[] topicFilters)
  10. {
  11. if (client == null) throw new ArgumentNullException(nameof(client));
  12. if (topicFilters == null) throw new ArgumentNullException(nameof(topicFilters));
  13. return client.SubscribeAsync(topicFilters.ToList());
  14. }
  15. public static Task UnsubscribeAsync(this IMqttClient client, params string[] topicFilters)
  16. {
  17. if (client == null) throw new ArgumentNullException(nameof(client));
  18. if (topicFilters == null) throw new ArgumentNullException(nameof(topicFilters));
  19. return client.UnsubscribeAsync(topicFilters.ToList());
  20. }
  21. }
  22. }