new WebSocketTransport()
- Source:
Methods
(static) ConnectionInfo(host, port)
Create a new WebSocketTransport.ConnectionInfo which extends
Transport.ConnectionInfo to hold the host and port info for the WebSocket
connection.
Parameters:
Name | Type | Description |
---|---|---|
host |
string | The host for the connection. However, if the host string begins with "ws:" or "wss:", then ignore port and use the string as the full endpoint URI. |
port |
number | (optional) The port number for the connection. If omitted, use 9696. |
- Source:
close()
Close the connection.
connect(connectionInfo, elementListener, onopenCallback, onclosedCallback)
Connect to a WebSocket according to the info in connectionInfo. Listen on
the port to read an entire packet element and call
elementListener.onReceivedElement(element). Note: this connect method
previously took a Face object which is deprecated and renamed as the method
connectByFace.
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
WebSocketTransport.ConnectionInfo | A WebSocketTransport.ConnectionInfo. |
elementListener |
object | The elementListener with function onReceivedElement which must remain valid during the life of this object. |
onopenCallback |
function | Once connected, call onopenCallback(). |
onclosedCallback |
function | (optional) If the connection is closed by the remote host, call onclosedCallback(). If omitted or null, don't call it. |
connectByFace()
- Deprecated:
- This is deprecated. You should not call Transport.connect directly, since it is called by Face methods.
- Source:
isLocal(connectionInfo, onResult, onError)
Determine whether this transport connecting according to connectionInfo is to
a node on the current machine. WebSocket transports are always non-local.
Parameters:
Name | Type | Description |
---|---|---|
connectionInfo |
WebSocketTransport.ConnectionInfo | This is ignored. |
onResult |
function | This calls onResult(false) because WebSocket transports are always non-local. |
onError |
function | This is ignored. |
send()
Send the Uint8Array data.