JsDoc Reference - jsf.push (original) (raw)

Namespace jsf.push

The Push functionality.

Defined in: jsf.js.

Namespace Summary

Constructor Attributes Constructor Name and Description
jsf.push The Push functionality.

Method Summary

Method Attributes Method Name and Description
jsf.push.close(clientId) Close the websocket on the given client identifier.
jsf.push.init(clientId, url, channel, onopen, onmessage, onclose, behaviors, autoconnect) Initialize a websocket on the given client identifier.
jsf.push.open(clientId) Open the websocket on the given client identifier.

Namespace Detail

jsf.push

The Push functionality.

Method Detail

jsf.push.close(clientId)

Close the websocket on the given client identifier.

Parameters:

{string} clientId

The client identifier of the websocket.

Throws:

{Error}

When client identifier is unknown. You may need to initialize it first via init() function.


jsf.push.init(clientId, url, channel, onopen, onmessage, onclose, behaviors, autoconnect)

Initialize a websocket on the given client identifier. When connected, it will stay open and reconnect as long as URL is valid and jsf.push.close() hasn't explicitly been called on the same client identifier.

Parameters:

{string} clientId

The client identifier of the websocket.

{string} url

The URL of the websocket. All open websockets on the same URL will receive the same push notification from the server.

{string} channel

The channel name of the websocket.

{function} onopen

The JavaScript event handler function that is invoked when the websocket is opened. The function will be invoked with one argument: the client identifier.

{function} onmessage

The JavaScript event handler function that is invoked when a message is received from the server. The function will be invoked with three arguments: the push message, the client identifier and the raw MessageEvent itself.

{function} onclose

The JavaScript event handler function that is invoked when the websocket is closed. The function will be invoked with three arguments: the close reason code, the client identifier and the rawCloseEvent itself. Note that this will also be invoked on errors and that you can inspect the close reason code if an error occurred and which one (i.e. when the code is not 1000). See alsoRFC 6455 section 7.4.1 andCloseCodes API for an elaborate list.

{Object} behaviors

Client behavior functions to be invoked when specific message is received.

{boolean} autoconnect

Whether or not to automatically connect the socket. Defaults to false.


jsf.push.open(clientId)

Open the websocket on the given client identifier.

Parameters:

{string} clientId

The client identifier of the websocket.

Throws:

{Error}

When client identifier is unknown. You may need to initialize it first via init() function.


Documentation generated by JsDoc Toolkit 2.0.2 on Tue Sep 05 2017 18:26:11 GMT-0400 (EDT)