WebSocket
Supports the standard WebSocket feature. On top of this, the WebSocket constructor is extended, as shown below.
WebSocket WebSocket(url, protocols, caFilePath, extensions)The constructor returns a WebSocket object.
Parameters
string url: the URL to connect to; this should be the URL to which the WebSocket server will respond
string | Array<string> protocols: [optional] a single protocol string or an array of protocol strings. These strings are used to specify sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to be able to handle different types of interactions depending on the specified protocol). If no protocol string is specified, it is an empty string.
string caFilePath: [optional] configures the path of the custom certificate supported by wss
Object extensions: [optional] extension data, described in the table below
extensions properties:
| Property | Type | Required | Description |
|---|---|---|---|
| header | Object | No | HTTP Header; Referer cannot be set in the Header. Defaults to {} |
| tcpNoDelay | boolean | No | TCP_NODELAY setting when establishing the TCP connection. Defaults to false |
| perMessageDeflate | boolean | No | Whether to enable the compression extension. Defaults to false |
| timeout | number | No | Timeout, in milliseconds. Defaults to 60000 |
Return Value
- WebSocket: returns a
WebSocketobject.
