WebSocket-API

Client can communicate with the RuuviTracker server using WebSocket API.

All messages are JSON formatted strings.

= Client to Server Messages =

No connection state is stored to server when connection closes. E.g. if connection closes and client reconnects, it must make subscribe requests again.

Subscribe trackers
Sent when client wishes to get new events from tracker. All subsequent events from the subscribed trackers are sent to client via WebSocket connection.

Request {"subscribe": "trackers", "ids": ["4", "5"]}

Reply TODO

Unsubscribe trackers
Sent when client no long wishes the get updates from trackers

Request {"unsubscribe": "trackers", "ids": ["4", "5", "42"]}

Reply TODO

= Server to Client messages =

Server sends incoming events from trackers to subscribed clients. Format of messages is identical to *events* message in UI-API

{events: [{"id": "123", "event_time": "2013-01-30T22:55:00,000Z" "tracker_id": "42"}, {"id": "125", "tracker_id": "412", "event_time": "2013-01-30T22:56:00,000Z"}, ]}