private async void SearchTopicChanged(string oldTopic) { if (!string.IsNullOrWhiteSpace(oldTopic)) { if (!TagValueViewModels.Any(t => t.Topic == oldTopic)) { client.Unsubscribe(oldTopic); log.Add($"{DateTime.Now}: Unsubscribed from topic {oldTopic}"); } } if (!string.IsNullOrWhiteSpace(SearchTopic)) { if (!TagValueViewModels.Any(t => t.Topic == SearchTopic)) { client.Subscribe(SearchTopic); log.Add($"{DateTime.Now}: Subscribed to topic {SearchTopic}"); } } Tags = new ObservableCollection <TagTopicViewModel>(); }
private void btnUbsubscribe_Click(object sender, EventArgs e) { string[] topics = { "sensor/temp", "sensor/humidity" }; client.Unsubscribe(topics); }
public void Unsubscribe() { client.Unsubscribe(new string[] { topic }); client.MqttMsgPublishReceived -= Client_MqttMsgPublishReceived; }