import { type WsFrame, type WsTimers } from "./frames.js"; import { PortSocketCore } from "./socket-core.js"; export interface ServerWebSocketOptions { /** The url the client asked for. */ url?: string; /** The subprotocol the server picked, `""` for none. */ protocol?: string; timers?: WsTimers; /** How long `close()` waits for the client's echo, in ms. Default 5 s. */ closeTimeoutMs?: number; } /** * The server end of a socket over a `MessagePort`: what a handler gets from * `upgradeWebSocket` and talks to. * * - Events are delivered only after `accept()`; frames that arrive earlier are * queued. Pings are answered even before `accept()`, so a slow handler does * not look like a dead one. * - Messages arrive as strings or `ArrayBuffer`s. * - `bufferedAmount` counts what the client has not consumed yet, and * `whenDrained(limit)` waits for it to fall: the backpressure a producer * applies. * - When the client's pings stop for three heartbeat periods (a closed tab, a * terminated worker), the socket closes with 1006. */ export declare class ServerWebSocket extends PortSocketCore { static readonly CONNECTING = 0; static readonly OPEN = 1; static readonly CLOSING = 2; static readonly CLOSED = 3; readonly url: string; readonly protocol: string; private _accepted; private _queue; private _heartbeatMs; private _lastPing; private _watch; constructor(port: MessagePort, options?: ServerWebSocketOptions); /** Whether `accept()` was called. */ get accepted(): boolean; /** Starts delivering events, the queued ones first. */ accept(): void; send(data: string | ArrayBuffer | ArrayBufferView): void; close(code?: number, reason?: string): void; protected _deliver(frame: Extract): void; protected _dispatchMessage(data: string | ArrayBuffer): void; protected _onPing(hb: number): void; protected _onClosed(): void; private _watchHeartbeat; } //# sourceMappingURL=server.d.ts.map