import { EventEmitter } from 'events'; import { Socket } from './socket'; import type { Context } from 'hono'; import { Transport } from './transport'; import type { Server as BunServer } from 'bun'; export interface ServerOptions { /** * how many ms without a pong packet to consider the connection closed * @default 20000 */ pingTimeout?: number; /** * how many ms before sending a new ping packet * @default 25000 */ pingInterval?: number; /** * The low-level transports that are enabled. */ transports?: 'websocket'; /** * parameters of the WebSocket permessage-deflate extension (see ws module api docs). Set to false to disable. * @default false */ perMessageDeflate?: boolean | object; /** * Max allowed payload size, in bytes. Set to false to disable. */ maxPayload?: number; /** * an optional packet which will be concatenated to the handshake packet emitted by Engine.IO. */ initialPacket?: any; } export declare class Server extends EventEmitter { opts: ServerOptions; bun: BunServer; protected clients: Map; clientsCount: number; constructor(bun: BunServer, opts?: Partial); /** * Handles a request with ctx and return ws context. * [onOpen, onClose, onMessage, onError] * * Set data to false to trigger auth error * * @param {Context} ctx Hono Context * @param {any|false} data Custom data for socket */ handleRequest(ctx: Context, data?: any | false): Transport; publish(topics: string | string[], encodedPackets: Array, opts?: { compress?: boolean; }): void; /** * Closes all clients. */ close(terminate?: boolean): void; /** * Cleans up the server. */ private cleanup; }