This library handles all the nitty-gritty details of talking to your sockethub.
Include sockethub-client.js script:
Create a client and wait for the "registered" event to fire:
var sockethubClient = SockethubClientsockethubClient;
When using ssl, add a field
ssl: true to the options in the
You may also want to set up some error handlers:
for more information, see: Quickstart
Out of the box,
SockethubClient implements these events:
connected- Fired once the WebSocket connection is established (i.e. socket.onopen has been called)
failed- Fired when the WebSocket connection failed to be established
disconnected- Fired when the WebSocket connection is closed (but it had been connected)
reconnecting- Fired when the WebSocket connection is closed, but configuration is set to reconnect (default)
message- Fired when the hub sends a message that isn't associated to a specific request.
unexpected-response- Fired when a response is received that carries a "rid" attribute, but that "rid" isn't known to us. This is an error case (and probably indicates a bug in the corresponding sockethub platform).
registered- Fired when
registration-failed- Fired when
The following properties are available for your use:
options- This is the options object that was passed to
connected- Boolean property reflecting the connection state of the socket.
registered- Boolean property. Initially false, set to the result of the
registercommand once that returns.
Currently the AMD module and the simple client are separate code-bases. For more info on using Sockethub with AMD see the doc here: AMD