Qore SewioWebSocketClient Module Reference 1.2
|
the main Sewio websocket client class More...
#include <SewioWebSocketClient.qm.dox.h>
Inherits WebSocketClient::WebSocketClient.
Public Member Methods | |
constructor (code cb, hash opts) | |
creates the object and optionally sets logging targets | |
hash | getSchemes () |
returns a hash of URL scheme information for URL schemes supported by this object | |
sendData (string method, string resource, *hash h) | |
sends data to the server | |
Public Attributes | |
const | DefaultUserAgent = sprintf("Qore-SewioWebSocketClient/%s", SewioWebSocketClient::Version) |
default user agent string for HTTP requests | |
const | RequiredOptions = ... |
required options | |
const | Version = "1.0" |
module version | |
Private Member Methods | |
hash | connectUnlocked (*hash hdr, *reference< hash > info) |
connects to the target server and starts the event listener thread | |
Static Private Member Methods | |
static code | getCallback (code cb) |
extern callback wrapper to parse the JSON and call the user's callback with the deserialized data | |
the main Sewio websocket client class
To use this class, create a SewioWebSocketClient object and the call WebSocketClient::connect().
The WebSocketClient::connect() method starts a background thread to receive messages, which are then posted to the callback provided in the SewioWebSocketClient::constructor() method call.
To stop listening for web socket events, call WebSocketClient::disconnect().
To send data to the Sewio RTLS Studio server, use the SewioWebSocketClient::send() method; this method will serialize the data to JSON and send the JSON string to the server.
When websocket messages are received from the server, they are deserialized and the resulting data is used as the argument to the callback closure mentioned above.
SewioWebSocketClient::SewioWebSocketClient::constructor | ( | code | cb, |
hash | opts | ||
) |
creates the object and optionally sets logging targets
cb | the callback closure or call reference for received messages; this callback must accept a *hash argument as it will only be called with deserialized data until the connection is closed, at which time it will be called with NOTHING |
opts | an option hash for the HTTPClient constructor plus the following keys:
|
SEWIOWEBSOCKETCLIENT-ERROR | unknown scheme, missing or invalid 'url' or 'apikey' key in option hash |