Namespace: push

jsf. push

The Push functionality.

Source:

Methods

(static) close(clientId)

Close the websocket on the given client identifier.
Parameters:
Name Type Description
clientId string The client identifier of the websocket.
Source:
Throws:
When client identifier is unknown. You may need to initialize it first via init() function.
Type
Error

(static) 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:
Name Type Description
clientId string The client identifier of the websocket.
url string The URL of the websocket. All open websockets on the same URL will receive the same push notification from the server.
channel string The channel name of the websocket.
onopen function The JavaScript event handler function that is invoked when the websocket is opened. The function will be invoked with one argument: the client identifier.
onmessage function 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.
onclose function 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 raw CloseEvent 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 also RFC 6455 section 7.4.1 and CloseCodes API for an elaborate list.
behaviors Object Client behavior functions to be invoked when specific message is received.
autoconnect boolean Whether or not to automatically connect the socket. Defaults to false.
Source:

(static) open(clientId)

Open the websocket on the given client identifier.
Parameters:
Name Type Description
clientId string The client identifier of the websocket.
Source:
Throws:
When client identifier is unknown. You may need to initialize it first via init() function.
Type
Error