import WebSocket = require('ws'); import { IrisAPI } from '@/services/core/IrisAPI'; import { IrisRequest } from '@/types/models/base'; import { Logger } from '@/utils/logger'; export interface ConnectionConfig { id: string; url: string; enabled?: boolean; priority?: number; } export interface ConnectionState { id: string; url: string; status: 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error'; ws?: WebSocket; api: IrisAPI; botId?: string; reconnectAttempts: number; lastError?: Error; lastConnectedAt?: Date; messageCount: number; } export interface MultiConnectionManagerOptions { maxReconnectAttempts?: number; initialReconnectDelay?: number; maxReconnectDelay?: number; connectionTimeout?: number; healthCheckInterval?: number; } /** * 여러 Iris 서버에 동시에 연결을 관리하는 클래스 */ export declare class MultiConnectionManager { private connections; private logger; private options; private onMessageCallback?; private healthCheckTimer?; private isRunning; constructor(logger: Logger, options?: MultiConnectionManagerOptions); /** * 연결 설정 추가 */ addConnection(config: ConnectionConfig): void; /** * 여러 연결 설정 한 번에 추가 */ addConnections(configs: ConnectionConfig[]): void; /** * URL 정리 */ private cleanUrl; /** * 메시지 핸들러 설정 */ setMessageHandler(callback: (data: IrisRequest, connectionId: string) => Promise): void; /** * 특정 연결의 봇 ID 가져오기 */ getBotId(connectionId?: string): string | undefined; /** * 특정 연결의 API 인스턴스 가져오기 */ getApi(connectionId?: string): IrisAPI | undefined; /** * 모든 연결 시작 */ connectAll(): Promise; /** * 단일 연결 (재시도 포함) */ private connectWithRetry; /** * 단일 연결 시도 */ private connect; /** * 메시지 처리 */ private handleMessage; /** * 연결 끊김 대기 */ private waitForDisconnection; /** * 헬스 체크 시작 */ private startHealthCheck; /** * 헬스 체크 수행 */ private performHealthCheck; /** * 모든 연결 상태 가져오기 */ getConnectionStates(): Map; /** * 연결 통계 가져오기 */ getStats(): { total: number; connected: number; disconnected: number; error: number; totalMessages: number; }; /** * WebSocket 없이 봇 정보 초기화 (HTTP 모드용) */ initializeBotInfo(): Promise; /** * 모든 연결 종료 */ close(): void; /** * 특정 연결 종료 */ closeConnection(connectionId: string): void; /** * 특정 연결 재시작 */ restartConnection(connectionId: string): Promise; private sleep; } //# sourceMappingURL=MultiConnectionManager.d.ts.map