plug-n-play-ws
Version:
A plug-and-play WebSocket layer on top of Socket.IO with full TypeScript support, zero manual wiring, and production-ready features
45 lines (42 loc) • 1.54 kB
TypeScript
import { E as EventMap, f as ClientConfig, a as SearchQuery, c as SearchResponse, C as ConnectionStatus, S as SessionMetadata } from '../types-BQpUMSaB.js';
import 'zod';
declare class PlugNPlayClient<T extends Record<string, unknown> = EventMap> {
private config;
private socket;
private emitter;
private logger;
private status;
private sessionId?;
private sessionMetadata?;
private reconnectAttempts;
private heartbeatInterval?;
private lastPongTime;
constructor(config: ClientConfig);
on<K extends keyof T>(event: K, listener: (data: T[K]) => void): this;
off<K extends keyof T>(event: K, listener: (data: T[K]) => void): this;
emit<K extends keyof T>(event: K, data: T[K]): boolean;
once<K extends keyof T>(event: K, listener: (data: T[K]) => void): this;
removeAllListeners<K extends keyof T>(event?: K): this;
connect(): Promise<void>;
disconnect(): void;
clearSession(): void;
send<K extends keyof T>(event: K, data: T[K]): boolean;
search(query: SearchQuery): Promise<SearchResponse | null>;
getStatus(): ConnectionStatus;
getSession(): {
id?: string;
metadata?: SessionMetadata;
};
isConnected(): boolean;
getStats(): {
status: ConnectionStatus;
sessionId: string | undefined;
reconnectAttempts: number;
lastPongTime: number;
connected: boolean;
};
private setupSocketHandlers;
private setStatus;
private startHeartbeat;
}
export { PlugNPlayClient };