Class: WebSocketJson

WebSocketJson(userOptions)

new WebSocketJson(userOptions)

Data source which connects to a websocket server, parses a JSON object out of websocket frames, and calls data handlers with the parsed object. This source can also respond to each frame received with a static value, allowing servers to rate limit data based on how quickly the client can respond.

Each WebSocketJson instance creates its own websocket connection.

Parameters:
Name Type Description
userOptions WebSocketJson.Options

User provided options

Source:

Methods

addHandler(handler)

Adds a handler function to be called when a websocket frame is received by this data source.

Parameters:
Name Type Description
handler function

function called with the websocket frame object as the single argument.

Source:

removeHandler(handler)

Removes a registered handler function if it exists in this data source

Parameters:
Name Type Description
handler function

function to be removed

Source:

Type Definitions

Options

These are the options specific to this class.

Properties:
Name Type Description
type String

Data source type. Must be "WebSocketJson",

url String

Websocket server url. (e.g. "ws://localhost:8001")

ackFrame String

Optional value to send as an acknowledgement to the websocket server after each frame is received. If this option is undefined, no acknowledgement will be sent.

Source: