Interface RealtimeWebSocket

Minimal WebSocket surface the transport depends on. The global WebSocket constructor (browsers, and Node's built-in client since Node 22) already satisfies this; pass webSocketFactory to supply a polyfill or a mock in tests without adding a runtime dependency.

interface RealtimeWebSocket {
    onclose: null | ((event: RealtimeWebSocketCloseEvent) => void);
    onerror: null | ((event: Event) => void);
    onmessage: null | ((event: MessageEvent<string>) => void);
    onopen: null | ((event: Event) => void);
    readyState?: number;
    close(code?: number, reason?: string): void;
    send(data: string): void;
}

Properties

onclose: null | ((event: RealtimeWebSocketCloseEvent) => void)
onerror: null | ((event: Event) => void)
onmessage: null | ((event: MessageEvent<string>) => void)
onopen: null | ((event: Event) => void)
readyState?: number

Methods