Skip to content

Class: WebSocketConnection ​

Defined in: api/rust-fetch.d.ts:919

A WebSocket connection created by WasmClient.websocket()

Properties ​

bufferedAmount ​

readonly bufferedAmount: number

Defined in: api/rust-fetch.d.ts:940

Bytes queued by the socket but not yet sent


closed ​

readonly closed: Promise<WebSocketCloseInfo>

Defined in: api/rust-fetch.d.ts:944

Resolves with the close code and reason once the connection is closed for good


opened ​

readonly opened: Promise<void>

Defined in: api/rust-fetch.d.ts:948

Resolves when the first connection opens; rejects if it never does


protocol ​

readonly protocol: string

Defined in: api/rust-fetch.d.ts:952

The subprotocol the server selected, or ""


state ​

readonly state: WebSocketState

Defined in: api/rust-fetch.d.ts:956

connecting, open, reconnecting, closing or closed


url ​

readonly url: string

Defined in: api/rust-fetch.d.ts:960

The connection URL (ws: or wss:)

Methods ​

[dispose]() ​

[dispose](): void

Defined in: api/rust-fetch.d.ts:922

Returns ​

void


close() ​

close(code?, reason?): void

Defined in: api/rust-fetch.d.ts:927

Close the connection and stop reconnecting. code is 1000 (the default) or 3000-4999; reason is at most 123 bytes of UTF-8.

Parameters ​

code? ​

number | null

reason? ​

string | null

Returns ​

void


free() ​

free(): void

Defined in: api/rust-fetch.d.ts:921

Returns ​

void


send() ​

send(data): void

Defined in: api/rust-fetch.d.ts:936

Send a message. Before the connection opens (or while reconnecting), messages are queued and sent once it does.

Parameters ​

data ​

WebSocketData

Returns ​

void


sendJson() ​

sendJson(value): void

Defined in: api/rust-fetch.d.ts:931

Send a value as JSON text

Parameters ​

value ​

any

Returns ​

void

Released under the MIT or Apache-2.0 license.