Websockets
In order to be able to receive events from devices, a websocket connection can be established.
Endpoint
The following url can be used to establish a websocket connection:
URL parameters
hostIp: ip address of the API host.
deviceId: (optional) device id. If the deviceId parameter is not passed, events for all configured device are received.
version (optional): defines the version of the received messages. This value may be left empty, header based versioning can be used instead.
v1 : default version if header is not present. The message is backwards compatible with ATPlatform websocket messages. The ‘data’ property in the message contains escape characters ‘' and is not JSON compliant.
v2 : message is JSON compliant.
header parameters
Authorization: bearer access token.
x-api-version: (optional). defines the version of the received messages. This option is deprecated and does not work for javascript clients, use the {version} url parameter (see above) instead! Note that this option is mutual exclusive with the url based versioning option.
1 : default version if header is not present. The message is backwards compatible with ATPlatform websocket messages. The ‘data’ property in the message contains escape characters ‘' and is not JSON compliant.
2 : message is JSON compliant.
- GET wss://{hostIp}:7081/{version}/halevents?deviceId={deviceId_1}&deviceId={deviceId_2}
Note
Note that the wss scheme is used to setup a secure websocket connection.
Ping message
In order for the api to be able to cleanup stale websocket connections (eg: in case of an unexpected termination of a client), ‘ping’ messages are sent the each connected client.
The client does NOT need to send a reply on these messages. The ping message has the following format:
"messageType":0,
"data": "ping"