Ejemplo n.º 1
0
 public void Unsubscribe(string topic, MQTTHandler handler)
 {
     if (mqttHandlers.ContainsKey(topic))
     {
         mqttHandlers [topic] -= handler;
     }
 }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
 private void Awake()
 {
     if (instanceInternal != null && instanceInternal != this)
     {
         Destroy(gameObject);
     }
     instanceInternal = this;
     DontDestroyOnLoad(gameObject);
 }
Ejemplo n.º 4
0
    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 });
    }