API reference › @evolu/common › WebSocket › WebSocketOptions
Defined in: packages/common/src/WebSocket.ts:135
Options for creating WebSocket.
Properties
binaryType?
readonly optional binaryType?: "blob" | "arraybuffer";
Defined in: packages/common/src/WebSocket.ts:140
Sets the binary type for the data being received.
onClose?
readonly optional onClose?: (event: CloseEvent) => void;
Defined in: packages/common/src/WebSocket.ts:149
Callback when the connection is closed.
onError?
readonly optional onError?: (error: WebSocketError) => void;
Defined in: packages/common/src/WebSocket.ts:146
Callback when an error occurs.
onMessage?
readonly optional onMessage?: (data:
| string
| ArrayBuffer
| Blob) => void;
Defined in: packages/common/src/WebSocket.ts:159
Callback when message data is received.
onOpen?
readonly optional onOpen?: () => void;
Defined in: packages/common/src/WebSocket.ts:143
Callback when the connection is established.
protocols?
readonly optional protocols?: string | readonly string[];
Defined in: packages/common/src/WebSocket.ts:137
Protocol(s) to use with the WebSocket connection.
schedule?
readonly optional schedule?: Schedule<number & Brand<"NonNaN"> & Brand<"Finite"> & Brand<"Int"> & Brand<"NonNegative"> & Brand<"LessThan281474976710655"> & Brand<"Millis">, WebSocketRetryError>;
Defined in: packages/common/src/WebSocket.ts:165
Retry schedule for reconnection. Defaults to webSocketReconnectSchedule.
shouldRetryOnClose?
readonly optional shouldRetryOnClose?: (event: CloseEvent) => boolean;
Defined in: packages/common/src/WebSocket.ts:156
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:174
For custom WebSocket implementations.
This supports blob: