public void SendMessage(Lamp lampState) { WebClient webClient = new WebClient(); webClient.BaseAddress = "http://" + bridgeIP + "/api/" + username + "/lights/" + lampState.GetLampNumber() + "/state"; Stream writeData = webClient.OpenWrite(webClient.BaseAddress, "PUT"); writeData.Write(Encoding.ASCII.GetBytes(lampState.GetJson()), 0, lampState.GetJson().Length); writeData.Close(); }
public void ChangeLampState(Lamp lamp, Delegate stateChange) { if (lamp == null) { return; } stateChange.DynamicInvoke(lamp); messaging.SendMessage(lamp); }
public Lamp ConvertToHueLamp(int lampNumber) { JsonLamp jsonLamp = null; lights.TryGetValue(lampNumber, out jsonLamp); if (jsonLamp != null) { Lamp lamp = new Lamp(lampNumber, jsonLamp.name, jsonLamp.state.on, jsonLamp.state.GetHueAsDegree(), jsonLamp.state.GetSaturation(), jsonLamp.state.GetBrightness()); return lamp; } return null; }