Example #1
0
        private void SendValue(string valueName)
        {
            string json;

            switch (valueName)
            {
            case "ambient_temperature":
                var ambientTemp = new Json.SetValue()
                {
                    type = "property_update", value_name = "ambient_temperature", value = GetRoom().AmbientTemperature
                };
                json = JsonConvert.SerializeObject(ambientTemp);
                SendJsonToAllClients(json);
                break;

            case "sun_state":
                var sunState = new Json.SetValue()
                {
                    type = "property_update", value_name = "sun_state", value = GetRoom().SunState
                };
                json = JsonConvert.SerializeObject(sunState);
                SendJsonToAllClients(json);
                break;
            }
        }
Example #2
0
        private void SendAllValues()
        {
            var room = GetRoom();

            if (null != room)
            {
                var ambientTemp = new Json.SetValue()
                {
                    type = "property_update", value_name = "ambient_temperature", value = room.AmbientTemperature
                };
                Send(JsonConvert.SerializeObject(ambientTemp));
                var sunState = new Json.SetValue()
                {
                    type = "property_update", value_name = "sun_state", value = room.SunState
                };
                Send(JsonConvert.SerializeObject(sunState));
            }
        }