コンテンツにスキップ

Interface: WebSocketSubscriptionOptions

このコンテンツはまだ日本語訳がありません。

Defined in: client/src/sync/websocket.ts:21

readonly url: string

Defined in: client/src/sync/websocket.ts:26

The full wss://…/sync/coordinator URL. A ?room=… query parameter is appended if room is supplied.


readonly optional room?: string

Defined in: client/src/sync/websocket.ts:28

Room to subscribe to. Defaults to “global”.


readonly optional token?: string | (() => string | Promise<string>)

Defined in: client/src/sync/websocket.ts:35

Shared secret required by the coordinator DO (matches its PLASMA_COORDINATOR_TOKEN env var). Passed as ?token= because browsers can’t attach custom headers to a WebSocket upgrade. Omit only when the DO is deliberately public.


readonly optional clientID?: string

Defined in: client/src/sync/websocket.ts:41

Presence identifier for this client. Also sent so the coordinator can broadcast which clientIDs are currently subscribed to the room. Omit to have the DO assign a random UUID.


readonly optional userInfo?: unknown

Defined in: client/src/sync/websocket.ts:43

Arbitrary JSON-serialisable presence payload (user name, colour, cursor…).


readonly optional onPresence?: (entries) => void

Defined in: client/src/sync/websocket.ts:45

Called when presence changes. Includes this client.

readonly PresenceEntry[]

void


readonly optional initialReconnectDelayMs?: number

Defined in: client/src/sync/websocket.ts:50

Milliseconds to wait before reconnecting after a close. Grows on each consecutive failure to avoid a tight reconnect loop. Defaults to 500.


readonly optional maxReconnectDelayMs?: number

Defined in: client/src/sync/websocket.ts:51


readonly optional WebSocketImpl?: (url, protocols?) => WebSocket

Defined in: client/src/sync/websocket.ts:56

Constructor for the WebSocket implementation. Defaults to the global WebSocket; used in tests to inject a fake transport.

string | URL

string | string[]

WebSocket