Skip to content

Websocket

Hundemeier edited this page Jun 21, 2018 · 1 revision

For the communication of KeyEvents is a websocket available. The endpoint is /websocket.

Data

The data that is send through the socket is always JSON data with the following structure:

{
  "Type": Int,
  "Data": <depends>,
  "Error": String,
  "Time": String, //RFC3339 encoded time of the event
}

Types

The available Types for the Type field are:

0: UNKNOWN
1: KEY_EVENT
2: CONFIG_WROTE
3: CONFIG_DELETE

Data Types

The Type of the Data field changes with the Type of the event. The UNKNOWN event has no data. The Error filed may have no data or has a value of "".

  • KEY_EVENT: The data is of the following structure:
...
"Data": {
  "KeyboardID": Int, //the ID of the keyboard from which the event originated
  "KeyCode": Int, //the keycode of the key that triggered the event
  "Value": Int //what happended in the event
}
...

Value can be one of the following:

0: KEY_UP //key was unpressed
1: KEY_DOWN //key was pressed
2: KEY_HOLD_DOWN //is send out every second if the key is hold down
  • CONFIG_WROTE and CONFIG_DELETE: The Data field is of type Boolean. If the action was successful, the value is true otherwise false and the Error field may contain more information.

Clone this wiki locally

⌂ 换网址