示例#1
0
        public void setKeyboardColors(List <byte> hids, List <Tuple <byte, byte, byte> > colors)
        {
            GameSensePayloadPeripheryColorEventJSON payload = new GameSensePayloadPeripheryColorEventJSON();

            payload.game  = sseGameName;
            payload.Event = "COLOR";

            payload.data  = "{";
            payload.data += "\"keyboard\":{";
            payload.data += "\"hids\":";
            payload.data += JsonConvert.SerializeObject(hids);
            payload.data += ",";
            payload.data += "\"colors\":[";
            foreach (Tuple <byte, byte, byte> color in colors)
            {
                payload.data += "[" + color.Item1 + ", " + color.Item2 + ", " + color.Item3 + "],";
            }
            // JSON doesn't allow trailing commas
            payload.data  = payload.data.TrimEnd(',');
            payload.data += "]";
            payload.data += "}";
            payload.data += "}";

            // sending POST request
            String json = JsonConvert.SerializeObject(payload);

            sendPostRequest("http://" + sseAddress + "/game_event", json);
        }
示例#2
0
        public void sendStop()
        {
            GameSensePayloadPeripheryColorEventJSON payload = new GameSensePayloadPeripheryColorEventJSON();

            payload.game  = sseGameName;
            payload.Event = "STOP";
            // sending POST request
            String json = JsonConvert.SerializeObject(payload);

            sendPostRequest("http://" + sseAddress + "/game_event", json);
        }
示例#3
0
        public void sendColor(String deviceType, byte red, byte green, byte blue)
        {
            GameSensePayloadPeripheryColorEventJSON payload = new GameSensePayloadPeripheryColorEventJSON();

            payload.game  = sseGameName;
            payload.Event = "COLOR";
            payload.data  = "{\"" + deviceType + "\":{\"color\": [" + red + ", " + green + ", " + blue + "]}}";
            // sending POST request
            String json = JsonConvert.SerializeObject(payload);

            sendPostRequest("http://" + sseAddress + "/game_event", json);
        }