private void MqttClient_Connected(object sender, MQTTnet.Client.Connecting.MqttClientConnectedEventArgs e) { StringBuilder str = new StringBuilder(); str.AppendLine("MQTT Connected!"); str.AppendLine($"Result code : {e.AuthenticateResult.ResultCode}"); WriteLog(str.ToString()); }
/// <summary> /// Subscribes to all the topics that we are interested in when a connection with the MQTT broker is established. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void MqttClient_Connected(object sender, MQTTnet.Client.Connecting.MqttClientConnectedEventArgs e) { //We defaulty listen to the switches channel. Will want to change this later depending on added buttons and such this.UpdateConnectionStatus(); List <string> topicsToSubscribeTo = new List <string>() { "Coffee", "WateringSystem", "WateringSystem/Status", "WateringSystem/Feedback", "Plant/Temperature", "Plant/Moisture", "Plant/Humidity", "Coffee/Status" }; foreach (string topic in topicsToSubscribeTo) { this.Subscribe(topic); } }
protected abstract void MqttClient_Connected(object sender, MQTTnet.Client.Connecting.MqttClientConnectedEventArgs e);