WebSocketTransport
The built-in ConnectionTransport: a WebSocket via #platform (native
in the browser, ws in Node so the User-Agent header can be sent). This is
what the library uses whenever no custom transport is supplied — connecting
to a WebSocket URL goes through WebSocketTransport.create, which
negotiates the SUBPROTOCOL subprotocol.
Implements
Methods
close()
close(): void;
Returns
void
Implementation of
send()
send(message): void;
Parameters
| Parameter | Type |
|---|---|
message | string |
Returns
void
Implementation of
create()
static create(
url,
headers?,
protocols?): Promise<WebSocketTransport>;
Opens a WebSocket to url and resolves once it is connected.
Parameters
| Parameter | Type |
|---|---|
url | string |
headers? | Record<string, string> |
protocols? | string | string[] |
Returns
Promise<WebSocketTransport>
Properties
| Property | Type |
|---|---|
onclose? | (event?) => void |
onerror? | (error) => void |
onmessage? | (message) => void |