Namespace: push

faces.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, onerror, 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 faces.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.
onerror function The JavaScript event handler function that is invoked when a connection error has occurred and the web socket will attempt to reconnect. The function will be invoked with three arguments: the error reason code, the channel name and the raw CloseEvent itself. Note that this will not be invoked on final close of the web socket, even when the final close is caused by an error. See also RFC 6455 section 7.4.1 and CloseCodes API for an elaborate list of all close codes.
onclose function The function to be invoked when the web socket is closed and will not anymore attempt to reconnect. The function will be invoked with three arguments: the close reason code, the channel name and the raw CloseEvent itself. Note that this will also be invoked when the close is caused by an error and that you can inspect the close reason code if an actual connection error occurred and which one (i.e. when the code is not 1000 or 1008). See also RFC 6455 section 7.4.1 and CloseCodes API for an elaborate list of all close codes.
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