Namespace: SockJS

CB_Net.Sockets. SockJS

Property that contains the functions and properties related with the SockJS client library.

Source:

Members


<static, readonly> websocketLast :Object|null

Keeps the last SockJS created.

Type:
  • Object | null
Source:

Methods


<static> close( [websocket] [, onError]) → {undefined|false}

Tries to close the websockets connection. Using the SockJS client library internally.

Parameters:
Name Type Argument Default Description
websocket function <optional>
CB_Net.Sockets.SockJS.websocketLast

The SockJS object that we want to use. If not provided, it will try to use the last one created (if any) which is stored in CB_Net.Sockets.SockJS.websocketLast.

onError function <optional>

Function for the event "onerror" used by the SockJS object. If provided, it will replace the previous one (if any). Following the same rules as in the SockJS client library documentation.

Source:
Returns:

Returns undefined (the same as the "close" function of the SockJS object) if the SockJS has been used or false otherwise.

Type
undefined | false

<static> listen(serverURL [, onOpen] [, onClose] [, onMessage] [, onError] [, options] [, protocols]) → {Object|null}

Creates the websockets object and sets the listeners. Using the SockJS client library internally.

Parameters:
Name Type Argument Description
serverURL string

The URL of the SockJS server. This will be used as the first parameter when it calls the constructor of SockJS internally. Following the same rules as in the SockJS client library documentation (the parameter is called "url").

onOpen function <optional>

Function for the event "onopen" used by the SockJS object. Following the same rules as in the SockJS client library documentation.

onClose function <optional>

Function for the event "onclose" used by the SockJS object. Following the same rules as in the SockJS client library documentation.

onMessage function <optional>

Function for the event "onmessage" used by the SockJS object. Following the same rules as in the SockJS client library documentation.

onError function <optional>

Function for the event "onerror" used by the SockJS object. Following the same rules as in the SockJS client library documentation.

options Object <optional>

The desired options for the SockJS object. This will be used as the third parameter when it calls the constructor of SockJS internally. Following the same rules as in the SockJS client library documentation (the parameter is called "options").

protocols array <optional>

This will be used as the second parameter when it calls the constructor of SockJS internally. Following the same rules as in the SockJS client library documentation (the parameter is called "_reserved").

Source:
Returns:

Returns a SockJS object. Read the SockJS client library documentation for more information. In the case of error, returns null.

Type
Object | null

<static> open()

Source:
See:

<static> send(message [, websocket] [, onError]) → {undefined|false}

Sends a websockets message. Using the SockJS client library internally.

Parameters:
Name Type Argument Default Description
message string

The message that we want to send. This will be used as the first and unique parameter when it calls the "send" function of the SockJS object internally. Following the same rules as in the SockJS client library documentation.

websocket function <optional>
CB_Net.Sockets.SockJS.websocketLast

The SockJS object that we want to use. If not provided, it will try to use the last one created (if any) which is stored in CB_Net.Sockets.SockJS.websocketLast.

onError function <optional>

Function for the event "onerror" used by the SockJS object. If provided, it will replace the previous one (if any). Following the same rules as in the SockJS client library documentation.

Source:
Returns:

Returns undefined (the same as the "send" function of the SockJS object) if the SockJS has been used or false otherwise.

Type
undefined | false