Ejemplo n.º 1
0
        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>();
        }
Ejemplo n.º 2
0
        private void btnUbsubscribe_Click(object sender, EventArgs e)
        {
            string[] topics = { "sensor/temp", "sensor/humidity" };

            client.Unsubscribe(topics);
        }
Ejemplo n.º 3
0
 public void Unsubscribe()
 {
     client.Unsubscribe(new string[] { topic });
     client.MqttMsgPublishReceived -= Client_MqttMsgPublishReceived;
 }