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.
 
 
 
 

26 rivejä
943 B

  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. }