public void Unsubscribe(string topic, MQTTHandler handler) { if (mqttHandlers.ContainsKey(topic)) { mqttHandlers [topic] -= handler; } }
/// <summary> /// Main window of the application. /// </summary> public HomeEditor() { Form loading = new Loading(); loading.Show(); loading.Refresh(); InitializeComponent(); defaultTitle = Text; roomNameBackground = roomName.BackColor; LoadRecents(); if (File.Exists(defaultFileName)) { try { DeserializeHome(defaultFileName); } catch (Exception exception) { MessageBox.Show("Invalid XML file.\nError: " + exception.Message, "Error"); } } LoadConfiguration(); Rule.OnNotification += SendAlert; ruleEngineTicker.Tick += RuleTick; ruleEngineTicker.Start(); #if DEBUG simulator.Visible = true; spoofSensor.Visible = true; spoofDoor.Visible = true; openDebugger.Visible = true; #endif MQTT = new MQTTHandler(Config.MQTTHost, Config.MQTTPort, Config.MQTTUser, Config.MQTTPass); loading.Close(); }
private void Awake() { if (instanceInternal != null && instanceInternal != this) { Destroy(gameObject); } instanceInternal = this; DontDestroyOnLoad(gameObject); }
public void On(string topic, MQTTHandler handler) { if (mqttHandlers.ContainsKey(topic)) { mqttHandlers [topic] += handler; } else { mqttHandlers [topic] = handler; } client.Subscribe(new string[] { topic }, new byte[] { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE }); }