API reference › @evolu/common › WebSocket › WebSocketOptions
Defined in: packages/common/src/WebSocket.ts:103
Options for creating WebSocket.
Properties
binaryType?
readonly optional binaryType?: "blob" | "arraybuffer";
Defined in: packages/common/src/WebSocket.ts:108
Sets the binary type for the data being received.
onClose?
readonly optional onClose?: (event: CloseEvent) => void;
Defined in: packages/common/src/WebSocket.ts:117
Callback when the connection is closed.
onError?
readonly optional onError?: (error: WebSocketError) => void;
Defined in: packages/common/src/WebSocket.ts:114
Callback when an error occurs.
onMessage?
readonly optional onMessage?: (data:
| string
| Blob
| ArrayBuffer) => void;
Defined in: packages/common/src/WebSocket.ts:127
Callback when message data is received.
onOpen?
readonly optional onOpen?: () => void;
Defined in: packages/common/src/WebSocket.ts:111
Callback when the connection is established.
protocols?
readonly optional protocols?: string | readonly string[];
Defined in: packages/common/src/WebSocket.ts:105
Protocol(s) to use with the WebSocket connection.
schedule?
readonly optional schedule?: Schedule<number & Brand<"Int"> & Brand<"NonNegative"> & Brand<"LessThan281474976710655"> & Brand<"Millis">, WebSocketRetryError>;
Defined in: packages/common/src/WebSocket.ts:137
Retry schedule for reconnection. Defaults to:
// A jittered, capped, unlimited exponential backoff.
jitter(1)(maxDelay("30s")(exponential("100ms")));
shouldRetryOnClose?
readonly optional shouldRetryOnClose?: (event: CloseEvent) => boolean;
Defined in: packages/common/src/WebSocket.ts:124
Determines whether a closed connection should trigger a retry.
Return false to stop retrying, for example on auth errors or maintenance.
WebSocketConstructor?
readonly optional WebSocketConstructor?: {
(url: string | URL, protocols?: string | string[]): WebSocket;
CLOSED: 3;
CLOSING: 2;
CONNECTING: 0;
OPEN: 1;
prototype: WebSocket;
};
Defined in: packages/common/src/WebSocket.ts:146
For custom WebSocket implementations.
This supports blob: