static int hbWebSocketClient_OnMessage(byte[] data, uint length, WebSocketClient.WEBSOCKET_PACKET_TYPES type, WebSocketClient.WEBSOCKET_RESULT_CODES result)
        {
            if (type == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__CLOSE)
            {
                hbWebSocketClient_OnClose(WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_ERROR, null);
            }
            _hbWebSocketClient.ReceiveAsync();
            var    e    = Encoding.Default.GetString(data, 0, data.Length);
            var    o    = JObject.Parse(e);
            string name = (string)o["payload"]["name"];

            //determine who the device belongs to....
            if (HBLightbulb.CheckIfDeviceExists(name) > 0)
            {
                HBLightbulb.ProcessWebsocketResponse(o);
            }
            else if (HBSwitch.CheckIfDeviceExists(name) > 0)
            {
                HBSwitch.ProcessWebsocketResponse(o);
            }
            else if (HBFan.CheckIfDeviceExists(name) > 0)
            {
                HBFan.ProcessWebsocketResponse(o);
            }
            else if (HBOutlet.CheckIfDeviceExists(name) > 0)
            {
                HBOutlet.ProcessWebsocketResponse(o);
            }
            else if (HBDoor.CheckIfDeviceExists(name) > 0)
            {
                HBDoor.ProcessWebsocketResponse(o);
            }
            else if (HBGarageDoor.CheckIfDeviceExists(name) > 0)
            {
                HBGarageDoor.ProcessWebsocketResponse(o);
            }
            else if (HBWindow.CheckIfDeviceExists(name) > 0)
            {
                HBWindow.ProcessWebsocketResponse(o);
            }
            else if (HBOccupancySensor.CheckIfDeviceExists(name) > 0)
            {
                HBOccupancySensor.ProcessWebsocketResponse(o);
            }
            else if (HBThermostat.CheckIfDeviceExists(name) > 0)
            {
                HBThermostat.ProcessWebsocketResponse(o);
            }
            else if (HBSecuritySystem.CheckIfDeviceExists(name) > 0)
            {
                HBSecuritySystem.ProcessWebsocketResponse(o);
            }
            return(0);
        }
        static void hbHttpClient_OnMessage(string data)
        {
            var o = JObject.Parse(data);

            //CrestronConsole.PrintLine("DataReceived - {0}", data);
            if (o["accessories"] != null)
            {
                foreach (var accessory in o["accessories"])
                {
                    string name = (string)accessory["services"][0]["characteristics"][3]["value"];
                    //determine who the device belongs to....
                    if (HBLightbulb.CheckIfDeviceExists(name) > 0)
                    {
                        HBLightbulb.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBSwitch.CheckIfDeviceExists(name) > 0)
                    {
                        HBSwitch.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBFan.CheckIfDeviceExists(name) > 0)
                    {
                        HBFan.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBOutlet.CheckIfDeviceExists(name) > 0)
                    {
                        HBOutlet.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBDoor.CheckIfDeviceExists(name) > 0)
                    {
                        HBDoor.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBGarageDoor.CheckIfDeviceExists(name) > 0)
                    {
                        HBGarageDoor.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBWindow.CheckIfDeviceExists(name) > 0)
                    {
                        HBWindow.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBOccupancySensor.CheckIfDeviceExists(name) > 0)
                    {
                        HBOccupancySensor.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBThermostat.CheckIfDeviceExists(name) > 0)
                    {
                        HBThermostat.ProcessHttpClientResponse(accessory);
                    }
                    else if (HBSecuritySystem.CheckIfDeviceExists(name) > 0)
                    {
                        HBSecuritySystem.ProcessHttpClientResponse(accessory);
                    }
                }
            }
        }