import type { WebSocket } from "ws"; /** Interval between heartbeat sweeps. ~30s is the standard NAT/proxy keep-alive floor. */ export declare const WS_HEARTBEAT_INTERVAL_MS = 30000; /** Minimal shape we need from a ws socket for liveness tracking. */ export interface HeartbeatSocket { isAlive?: boolean; readyState: number; ping(): void; terminate(): void; } /** * Mark a freshly-connected socket alive and refresh its liveness on every pong. * Call once per new connection. */ export declare function trackHeartbeat(ws: HeartbeatSocket & { on(event: "pong", cb: () => void): void; }): void; /** * Run one heartbeat sweep over a set of sockets: * - terminate() any socket still marked dead from the previous sweep * - otherwise mark it provisionally dead and ping() it; the pong handler * (installed by trackHeartbeat) flips it back to alive before the next sweep. * Returns counts for logging/testing. */ export declare function sweepHeartbeat(sockets: Iterable): { terminated: number; pinged: number; }; /** * Start a periodic heartbeat across one or more WebSocketServer-like objects * (anything exposing a `clients` Set). Returns a stop function that clears the * timer. The timer is unref()'d so it never keeps the process alive. */ export declare function startWsHeartbeat(servers: Array<{ clients: Set; }>, opts?: { intervalMs?: number; onSweep?: (result: { terminated: number; pinged: number; }) => void; }): () => void; //# sourceMappingURL=ws-heartbeat.d.ts.map