import type { ErrorPayload } from "./types.js"; import { type TransportType } from "./transport/index.js"; /** * Event handlers for the gateway client */ export interface GatewayClientEvents { connected?: () => void; disconnected?: () => void; registered?: (nodeId: string, name: string) => void; joinedGroup?: (groupId: string, groupName: string) => void; leftGroup?: (groupId: string) => void; broadcast?: (message: unknown, fromNodeId: string, groupId: string) => void; direct?: (message: unknown, fromNodeId: string) => void; error?: (error: ErrorPayload) => void; ping?: () => void; pong?: () => void; } /** * Gateway client options */ export interface GatewayClientOptions { token?: string; capabilities?: string[]; events?: GatewayClientEvents; transport?: TransportType | "auto"; } /** * Gateway client for connecting nodes to the gateway */ export declare class GatewayClient { private url; private transport; private nodeId; private nodeName; private token?; private capabilities?; private events; private reconnectAttempts; private maxReconnectAttempts; private reconnectDelay; private pingInterval; private transportType; private logger; private ws; constructor(url: string, name: string, options?: GatewayClientOptions); /** * Connect to the gateway */ connect(): Promise; /** * Select appropriate transport type */ private selectTransport; /** * Create transport instance */ private createTransport; /** * Disconnect from the gateway */ disconnect(): void; /** * Register with the gateway */ private register; /** * Join a broadcast group */ joinGroup(groupName: string, options?: { createIfNotExists?: boolean; description?: string; }): Promise; /** * Leave a broadcast group */ leaveGroup(groupId: string): Promise; /** * Broadcast a message to a group */ broadcast(groupId: string, message: unknown): void; /** * Send a direct message to another node */ sendDirect(targetNodeId: string, message: unknown): void; /** * Send a ping to the gateway */ ping(): void; /** * Handle incoming messages */ private handleMessage; /** * Handle acknowledgment message */ private handleAck; /** * Handle broadcast message */ private handleBroadcast; /** * Handle direct message */ private handleDirect; /** * Handle ping message */ private handlePing; /** * Handle pong message */ private handlePong; /** * Handle error message */ private handleError; /** * Handle disconnect */ private handleDisconnect; /** * Start ping interval */ private startPingInterval; /** * Send a message to the gateway */ private send; /** * Get the node ID */ getNodeId(): string | null; /** * Get the node name */ getNodeName(): string; /** * Check if connected */ isConnected(): boolean; }