Example #1
0
    void ReadTopics()
    {
        while (client.Count() > 0)
        {
            MqttMsgPublishEventArgs args = client.ReceiveEvent();

            string strData = string.Empty;
            for (int i = 0; i < args.Message.Length; i++)
            {
                strData += ((char)args.Message[i] - '0').ToString();
            }
            float val = float.Parse(strData);

            if (args.Topic == innerTempTopic)
            {
                EventManager.UpdateInnerTemp(val);
            }
            else if (args.Topic == innerHumidityTopic)
            {
                EventManager.UpdateInnerHumidity(val);
            }
            else if (args.Topic == shadeStateTopic)
            {
                EventManager.UpdateShadeState(val);
            }
            else if (args.Topic == windowStateTopic)
            {
                EventManager.UpdateWindowState(val);
            }
            else if (args.Topic == outerTempTopic)
            {
                EventManager.UpdateOuterTemp(val);
            }
            else if (args.Topic == outerLightTopic)
            {
                EventManager.UpdateOuterLight(val);
            }
            else if (args.Topic == outerWindTopic)
            {
                EventManager.UpdateOuterWind(val);
            }
            else
            {
                Debug.Log("This topic is not registered!!!: " + args.Topic);
            }
        }
    }