import { Server, type ServerOptions } from "engine.io"; import { type IncomingMessage } from "node:http"; import { type Packet } from "engine.io-parser"; type Brand = K & { __brand: T; }; type NodeId = Brand; type SessionId = Brand; type RequestId = Brand; declare enum MessageType { ACQUIRE_LOCK = 0, ACQUIRE_LOCK_RESPONSE = 1, DRAIN = 2, PACKET = 3, UPGRADE = 4, UPGRADE_RESPONSE = 5, CLOSE = 6 } export type Message = { senderId: NodeId; } & ({ requestId: RequestId; type: MessageType.ACQUIRE_LOCK; data: { sid: SessionId; transportName: string; type: "read" | "write"; }; } | { recipientId: NodeId; requestId: RequestId; type: MessageType.ACQUIRE_LOCK_RESPONSE; data: { success: boolean; }; } | { recipientId: NodeId; type: MessageType.DRAIN; data: { sid: SessionId; packets: Packet[]; }; } | { recipientId: NodeId; type: MessageType.PACKET; data: { sid: SessionId; packet: Packet; }; } | { requestId: RequestId; recipientId: NodeId; type: MessageType.UPGRADE; data: { sid: SessionId; success: boolean; }; } | { requestId: RequestId; recipientId: NodeId; type: MessageType.UPGRADE_RESPONSE; data: { takeOver: boolean; packets: Packet[]; }; } | { recipientId: NodeId; type: MessageType.CLOSE; data: { sid: SessionId; reason: string; }; }); interface ClusterEngineOptions { /** * The maximum waiting time for responses from other nodes, in ms. * * @default 1000 */ responseTimeout?: number; /** * The delay between two "noop" packets when the client upgrades, in ms. * * @default 200 */ noopUpgradeInterval?: number; /** * The maximum waiting time for a successful upgrade, in ms. * * @default 300 */ delayedConnectionTimeout?: number; } export declare abstract class ClusterEngine extends Server { private readonly _opts; protected readonly _nodeId: NodeId; private readonly _requests; private readonly _remoteTransports; private _requestCount; constructor(opts?: ServerOptions & ClusterEngineOptions); protected onMessage(message: Message): void; private _forwardFlushWhenPolling; private _forwardFlushWhenWebSocket; verify(req: IncomingMessage & { _query: Record; }, upgrade: boolean, fn: (errorCode?: number, context?: any) => void): void; private _acquireLock; private _hookTransport; private _tryUpgrade; private _onPacket; private _onClose; onWebSocket(req: any, socket: any, websocket: any): any; private _onUpgradeSuccess; emit(ev: string, ...args: any[]): boolean; private _doConnect; abstract publishMessage(message: Message): void; } export {};