Beispiel #1
0
 public void Unsubscribe_10000_Topics()
 {
     foreach (var topic in _topics)
     {
         var unsubscribeOptions = new MqttClientUnsubscribeOptionsBuilder()
                                  .WithTopicFilter(topic)
                                  .Build();
         _mqttClient.UnsubscribeAsync(unsubscribeOptions).GetAwaiter().GetResult();
     }
 }
        public static Task <MqttClientUnsubscribeResult> UnsubscribeAsync(this MqttClient mqttClient, string topic, CancellationToken cancellationToken = default)
        {
            if (mqttClient == null)
            {
                throw new ArgumentNullException(nameof(mqttClient));
            }

            if (topic == null)
            {
                throw new ArgumentNullException(nameof(topic));
            }

            var unsubscribeOptions = new MqttClientUnsubscribeOptionsBuilder().WithTopicFilter(topic)
                                     .Build();

            return(mqttClient.UnsubscribeAsync(unsubscribeOptions, cancellationToken));
        }