/*************************************************************************** * Sockular * * @author Nehonix * @license NOSL * * Copyright (c) 2025 Nehonix. All rights reserved. * * This License governs the use, modification, and distribution of software * provided by NEHONIX under its open source projects. * NEHONIX is committed to fostering collaborative innovation while strictly * protecting its intellectual property rights. * Violation of any term of this License will result in immediate termination of all granted rights * and may subject the violator to legal action. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, * AND NON-INFRINGEMENT. * IN NO EVENT SHALL NEHONIX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES ARISING FROM THE USE OR INABILITY TO USE THE SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * ***************************************************************************** */ import { Socket } from 'socket.io'; /** * Configuration options for SockularServer */ export interface SockularServerConfig { port: number; host?: string; enableLogging?: boolean; enableHeartbeat?: boolean; heartbeatInterval?: number; sessionTimeout?: number; maxConnections?: number; rateLimit?: { enabled: boolean; windowMs?: number; maxRequests?: number; message?: string; global?: boolean; }; } /** * WebSocket client information */ export interface WebSocketClient { id: string; socket: Socket; startTime: number; lastActivity: number; isActive: boolean; metadata: { userId?: string; sessionId?: string; isGuest?: boolean; [key: string]: any; }; } /** * Service handler interface */ export interface WebSocketServiceHandler { serviceName: string; handleMessage(socket: Socket, message: any, clientId: string): Promise; initialize?(server: any): Promise; handleDisconnection?(socket: Socket, clientId: string): void; shutdown?(): Promise; getServiceInfo?(): any; } /** * Middleware function type */ export type Middleware = (socket: Socket, data: any, clientId: string, next: () => Promise) => Promise; /** * Service decorator options */ export interface ServiceOptions { middleware?: string[]; rateLimit?: { maxRequests: number; windowMs: number; }; [key: string]: any; } /** * Message structure */ export interface SockularMessage { service: string; type: string; data: any; authenticatedUserId?: string; sessionId?: string; isGuest?: boolean; } /** * Metadata keys for decorators */ export declare const METADATA_KEYS: { readonly SERVICE_NAME: "sockular:service:name"; readonly SERVICE_OPTIONS: "sockular:service:options"; readonly SERVICE_MIDDLEWARE: "sockular:service:middleware"; readonly IS_SERVICE: "sockular:is:service"; readonly MESSAGE_HANDLERS: "sockular:message:handlers"; readonly LIFECYCLE_CONNECT: "sockular:lifecycle:connect"; readonly LIFECYCLE_DISCONNECT: "sockular:lifecycle:disconnect"; readonly METHOD_MIDDLEWARE: "sockular:method:middleware"; readonly METHOD_SKIP_MIDDLEWARE: "sockular:method:skipMiddleware"; readonly ROOM_JOIN: "sockular:room:join"; readonly ROOM_LEAVE: "sockular:room:leave"; readonly EMIT_TO_ROOM: "sockular:emit:to_room"; readonly SOCKET_IO_INJECT: "sockular:inject:socket_io"; }; /** * Message handler metadata */ export interface MessageHandlerMetadata { method: string; messageType: string; } //# sourceMappingURL=index.d.ts.map