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.

Arguments

Copied to clipboard!
Kuzzle(protocol, [options]);

Argument Type Description
protocol
Protocol
Protocol used by the SDK instance
options
object
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.

Property Type
(default)
Description
autoQueue
boolean

(false)
Automatically queue all requests during offline mode
autoReplay
boolean

(false)
Automatically replay queued requests on a reconnected event
autoResubscribe
boolean

(true)
Automatically renew all subscriptions on a reconnected event
eventTimeout
number

(200)
Time (in ms) during which a similar event is ignored
offlineMode
string

(manual)
Offline mode configuration. Can be manual or auto
queueTTL
number

(120000)
Time a queued request is kept during offline mode, in milliseconds
queueMaxSize
number

(500)
Number of maximum requests kept during offline mode
replayInterval
number

(10)
Delay between each replayed requests, in milliseconds
volatile
object

({})
Common volatile data, will be sent to all future requests

Return

The Kuzzle SDK instance.

Usage

Copied to clipboard!
// Loads the Kuzzle SDK module
const
  {
    Kuzzle,
    WebSocket,
    Http
  } = require('kuzzle-sdk');

const options = {
  offlineMode: 'auto',
  volatile: { username: 'Gordon' }
};

// Instantiates the SDK with the websocket protocol
const
  kuzzleWs = new Kuzzle(
    new WebSocket('kuzzle'),
    options
  );

// Instantiates the SDK with the http protocol
const
  kuzzleHttp = new Kuzzle(
    new Http('kuzzle')
  );