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)); }
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); }