コード例 #1
0
ファイル: MQTTnetClient.cs プロジェクト: davilu/edge-test
        public Task UnsubscribeAsync(IEnumerable <string> topics, CancellationToken cancellationToken)
        {
            var builder = new MqttClientUnsubscribeOptionsBuilder();

            foreach (string topic in topics)
            {
                builder.WithTopicFilter(topic);
            }
            return(client.UnsubscribeAsync(builder.Build(), cancellationToken));
        }
コード例 #2
0
        public async Task UnsubscribeAsync(string topic)
        {
            if (!IsSubscribed(topic))
            {
                return;
            }

            var options = new MqttClientUnsubscribeOptions();

            options.TopicFilters = new List <string> {
                topic
            };
            await client.UnsubscribeAsync(options);

            mqttState.RemoveSubscription(s => s.Topic == topic);
        }