Constructor #
This constructor creates a new WebSocket connection, using the specified options.
Arguments #
WebSocket(host, [options]);| Argument | Type | Description |
|---|---|---|
host | string | Kuzzle server hostname or IP |
options | object | WebSocket connection options |
options #
WebSocket protocol connection options.
| Property | Type (default) | Description |
|---|---|---|
autoReconnect | boolean ( true) | Automatically reconnect to kuzzle after a disconnected event |
port | number ( 7512) | Kuzzle server port |
headers | object( {}) | Connection HTTP headers (e.g. origin, subprotocols, ...) (Not supported by browsers) |
reconnectionDelay | number ( 1000) | Number of milliseconds between reconnection attempts |
sslConnection | boolean ( false) | Use SSL to connect to Kuzzle server |
Return #
A WebSocket protocol instance.
Usage #
// Loads the WebSocket protocol
const
{
Kuzzle,
WebSocket
} = require('kuzzle-sdk');
const options = {
autoReconnect: false
};
// Instantiates the websocket protocol
const websocketProtocol = new WebSocket('kuzzle', options);
// Use it with Kuzzle
const kuzzle = new Kuzzle(websocketProtocol);