Class: WebSocketConnector

WebSocketConnector(properties)

Defines the WebSocketConnector to connect to a remote server by creating a WebSocket channel.

Constructor

new WebSocketConnector(properties)

Parameters:
Name Type Description
properties -
Source:
Example
import WebSocketConnector from 'osh-js/dataconnector/WebSocketConnector.js';

let url = ...;
let connector = new WebSocketConnector(url);

// connect
connector.connect();

// disconnect
connector.disconnect();

// close
connector.close();

Extends

Methods

checkStatus(status)

Check a change of the status and call the corresponding callbacks if necessary
Parameters:
Name Type Description
status Status the currentStatus
Overrides:
Source:

(async) connect()

Connect to the webSocket. If the system supports WebWorker, it will automatically creates one otherwise use the main thread.
Source:

disconnect()

Disconnects and close the websocket.
Source:

getId() → {String}

The data protocol default id.
Overrides:
Source:
Returns:
Type
String

getUrl() → {String}

The stream url.
Overrides:
Source:
Returns:
Type
String

onChangeStatus(status)

Called when the connection STATUS changes
Parameters:
Name Type Description
status Status the new status
Overrides:
Source:

onConnect()

Called when the protocol has been connected
Overrides:
Source:

onDisconnect()

Called when the protocol has been disconnected
Overrides:
Source:

setReconnectTimeout(timeout)

Sets the reconnection timeout
Parameters:
Name Type Description
timeout Number delay in milliseconds before reconnecting dataSource
Overrides:
Source:

setUrl(url)

Sets the url
Parameters:
Name Type Description
url
Overrides:
Source:

Events

onMessage

The onMessage method used by the websocket to callback the data
Parameters:
Name Type Description
data the callback data
Source: