Skip to content

WebSocketTransport

Defined in: websocket.ts:53

A reconnecting, buffering, JSON-framed WebSocket transport.

Type Parameter
T
new WebSocketTransport<T>(url, options?): WebSocketTransport<T>;

Defined in: websocket.ts:74

ParameterType
urlstring
optionsWebSocketTransportOptions

WebSocketTransport<T>

get connectionStatus(): WebSocketStatus;

Defined in: websocket.ts:93

Current connection state.

WebSocketStatus

close(): void;

Defined in: websocket.ts:119

Permanently close this endpoint. Further sends are an error.

void

Transport.close


connect(): void;

Defined in: websocket.ts:98

Open the socket (and re-arm auto-reconnect). Safe to call when already open.

void


onMessage(handler): () => void;

Defined in: websocket.ts:114

Subscribe to inbound messages. Returns an unsubscribe function.

ParameterType
handler(message) => void

() => void

Transport.onMessage


send(message): void;

Defined in: websocket.ts:104

Push a message toward the peer(s) on the other side.

ParameterType
messageT

void

Transport.send