Constructor #
Use this constructor to create a new instance of the SDK. Each instance represent a different connection to a Kuzzle server with specific options.
Signature #
kuzzleio::Kuzzle(kuzzleio::Protocol* protocol);
kuzzleio::Kuzzle(kuzzleio::Protocol* protocol, const options& options);
Arguments #
Argument | Type | Description |
---|---|---|
protocol | Protocol\* | Protocol used by the SDK instance |
options | const kuzzleio::options& | Kuzzle object configuration |
protocol #
The protocol used to connect to the Kuzzle instance. It can be one of the following available protocols:
options #
Kuzzle SDK instance options.
Option | Type (default) | Description |
---|---|---|
auto_queue | bool ( false ) | Automatically queue all requests during offline mode |
auto_reconnect | bool ( true ) | Automatically reconnect after a connection loss |
auto_replay | bool ( false ) | Automatically replay queued requests on a EVENT_RECONNECTED event |
auto_resubscribe | bool ( true ) | Automatically renew all subscriptions on a EVENT_RECONNECTED event |
offline_mode | enum Mode ( MANUAL ) | Offline mode configuration. MANUAL or AUTO |
queue_ttl | unsigned ( 120000 ) | Time a queued request is kept during offline mode, in milliseconds |
queue_max_size | unsigned long ( 500 ) | Number of maximum requests kept during offline mode |
replay_interval | unsigned long ( 10 ) | Delay between each replayed requests, in milliseconds |
reconnection_delay | unsigned long ( 10000 ) | Number of milliseconds between reconnection attempts |
volatile | std::string ( "{}" ) | JSON string representing common volatile data, will be sent to all future requests |
Notes:
- if
queue_ttl
is set to0
, requests are kept indefinitely - The offline buffer acts like a first-in first-out (FIFO) queue, meaning that if the
queue_max_size
limit is reached, older requests are discarded to make room for new requests - if
queue_max_size
is set to0
, an unlimited number of requests is kept until the buffer is flushed - multiple methods allow passing specific
volatile
data. Thesevolatile
data will be merged with the global Kuzzlevolatile
object when sending the request, with the request specificvolatile
taking priority over the global ones.
Return #
A Kuzzle
instance.
Usage #
std::string hostname = "kuzzle";
kuzzleio::WebSocket* ws = new kuzzleio::WebSocket(hostname);
kuzzleio::Options options;
options.autoResubscribe(false);
kuzzleio::Kuzzle *kuzzle = new kuzzleio::Kuzzle(ws, options);
std::cout << "New SDK instance successfully created" << std::endl;
Edit this page on Github(opens new window)