UNPKG

bun-ws-router

Version:

Lightweight client/server WebSocket router for Bun with type-safe Zod/Valibot validation.

36 lines 1.04 kB
/** * Message queue management for offline buffering. * See @specs/client.md#queue-behavior. */ export type QueuePolicy = "drop-oldest" | "drop-newest" | "off"; export declare class MessageQueue { private policy; private maxSize; private queue; private overflowCallbacks; constructor(policy: QueuePolicy, maxSize: number); setOverflowCallback(cb: ((error: Error, context: { type: "overflow"; details?: unknown; }) => void) | null): void; removeOverflowCallback(cb: (error: Error, context: { type: "overflow"; details?: unknown; }) => void): void; /** * Enqueue a pre-serialized message. * Returns true if enqueued/sent, false if dropped. */ enqueue(message: string): boolean; /** * Flush all queued messages to WebSocket. * Returns number of messages sent. */ flush(ws: WebSocket): number; /** * Clear queue without sending. */ clear(): void; get size(): number; } //# sourceMappingURL=queue.d.ts.map