/*************************************************************************** * 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 'reflect-metadata'; import { Server as SocketIOServer } from 'socket.io'; import { EventEmitter } from 'events'; import { SockularServerConfig, Middleware } from '../types'; /** * SockularServer * Main server class that manages Socket.IO connections, services, and middleware */ export declare class SockularServer extends EventEmitter { private _io; private config; private serviceRegistry; private middlewareRegistry; private clients; private socketToClientId; private heartbeatInterval?; private isRunning; private clientIdCounter; constructor(config: SockularServerConfig); /** * Get the underlying Socket.IO server instance */ get io(): SocketIOServer; /** * Setup built-in rate limit middleware */ private setupRateLimit; /** * Register a middleware with a name */ registerMiddleware(name: string, middleware: Middleware): void; /** * Add a global middleware (applied to all messages) */ use(middlewareName: string): void; /** * Register a service class */ register(ServiceClass: any): void; /** * Automatically discover and register services from a directory */ discoverServices(directoryPath: string): Promise; /** * Recursively scan directory for service files */ private scanDirectory; /** * Setup Socket.IO server */ private setupWebSocketServer; /** * Setup heartbeat system */ private setupHeartbeat; /** * Check for session timeouts */ private checkSessionTimeouts; /** * Expire a client */ private expireClient; /** * Handle new connection */ private handleConnection; /** * Handle incoming message */ private handleMessage; /** * Build middleware chain for a method */ private buildMiddlewareChain; /** * Execute middleware chain */ private executeMiddlewares; /** * Update client activity */ private updateClientActivity; /** * Handle disconnection */ private handleDisconnection; /** * Start the server */ start(): Promise; /** * Shutdown the server */ shutdown(): Promise; /** * Get server stats */ getStats(): any; /** * Send message to a specific client */ sendToClient(clientId: string, event: string, data: any): boolean; /** * Broadcast to all clients */ broadcast(event: string, data: any): void; } //# sourceMappingURL=SockularServer.d.ts.map