/** * Connection Context Manager * * Manages Context per WebSocket connection * - Create Context on connection * - Query/update Context on event * - Delete Context on disconnection * - Periodic cleanup to prevent memory leaks */ import type { WsContext } from './types'; /** * Context Manager options */ export interface ContextManagerOptions { /** * Context maximum retention time (ms) * @default 86400000 (24 hours) */ maxAge?: number; /** * Cleanup interval (ms) * @default 60000 (1 minute) */ cleanupInterval?: number; /** * Debug logging * @default false */ debug?: boolean; } /** * Connection Context Manager class */ export declare class ConnectionContextManager { private contexts; private cleanupTimer; private readonly options; constructor(options?: ContextManagerOptions); /** * Create Context on connection * * @param socketId - Socket ID * @param initialData - Initial data * @returns Created Context */ create(socketId: string, initialData?: Partial): WsContext; /** * Get Context * * @param socketId - Socket ID * @returns Context or undefined */ get(socketId: string): WsContext | undefined; /** * Get Context if exists, create if not * * @param socketId - Socket ID * @param initialData - Initial data (used only on creation) * @returns Context */ getOrCreate(socketId: string, initialData?: Partial): WsContext; /** * Delete Context on disconnection * * @param socketId - Socket ID * @returns Whether deletion was successful */ delete(socketId: string): boolean; /** * Check if Context exists * * @param socketId - Socket ID * @returns Whether it exists */ has(socketId: string): boolean; /** * Total Context count */ get size(): number; /** * Cleanup expired Contexts * * @param maxAgeMs - Maximum retention time (default: options.maxAge) * @returns Number of cleaned up Contexts */ cleanup(maxAgeMs?: number): number; /** * Start periodic cleanup */ private startCleanup; /** * Stop periodic cleanup */ private stopCleanup; /** * Cleanup resources */ destroy(): void; /** * Return all Contexts (for debugging) */ getAll(): Map; /** * Debug log */ private log; } //# sourceMappingURL=context-manager.d.ts.map