Connecting to ChipChop
As the purpose of ChipChop is to provide a remote real-time » bi-directional communication between devices everything happens over a long lived WebSocket connection. So, the first thing will be to open a WebSocket connection with ChipChop
Initiating a connection
In order to establish a connection with ChipChop your device should attempt a WebSocket connection to your allocated Endpoint Server with your UUID and Device ID sent as query string parameters.
NOTE: This is the only time you won't be sending any JSON, all other exchange off data is in JSON format.
Abstract example in no particular language asuming you have some sort ofWebSocket class with a connect method
NOTE: This is the only time you won't be sending any JSON, all other exchange off data is in JSON format.
Abstract example in no particular language asuming you have some sort of
WebSocket.connect("ws://api.chipchop.io/wsdev/?uuid=your_user_uuid&device_id=your_device_id");
- Depending on the WebSocket library that you use the responses from ChipChop will arrive through whatever "message" mechanism that library employs
- There is no async "send request > receive response" logic as with HTTP requests or AJAX so things arrive as and when they happen
-
Your WebSocket library has to correctly implement the Ping/Pong part of the WebSocket protocol or you will keep loosing your connection - Be a champ and try to send a disconnect signal to ChipChop if you are putting your device to sleep or restarting so ChipChop can release the socket rather than faffing with pings