For AI agents: a documentation index is available at /llms.txt
Skip to main content

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​

ConnectionTransport.close


send()​

send(message): void;

Parameters​

ParameterType
messagestring

Returns​

void

Implementation of​

ConnectionTransport.send


create()​

static create(
url,
headers?,
protocols?): Promise<WebSocketTransport>;

Opens a WebSocket to url and resolves once it is connected.

Parameters​

ParameterType
urlstring
headers?Record<string, string>
protocols?string | string[]

Returns​

Promise<WebSocketTransport>

Properties​

PropertyType
onclose?(event?) => void
onerror?(error) => void
onmessage?(message) => void
Was this page helpful?