export interface Settings { /** * Server's port to connect to */ port: number; /** * Server host */ host?: string; /** * Use a secure connection */ ssl?: boolean; } export declare enum Errors { /** * The connection is already alive */ alreadyAlive = 0, /** * The connection is already starting */ alreadyStarting = 1, /** * The client failed to connect for an unknown reason */ failedToConnect = 2 } export default class TCPClient { /** * The event emitter */ private emitter; /** * The WebSocket client */ private webSocket?; /** * Client settings */ private _settings; /** * If the connection is alive */ private _alive; /** * If the connection is starting */ private _starting; /** * Error message caught from WebSocket */ private _exitError?; /** * This class is used to connect to TCP server * @param settings TCP host client settings */ constructor(settings: Settings); /** * Start the connection process to the server * @returns Promise for when the connection was successful */ start(): Promise; /** * If the connection is alive */ get alive(): boolean; /** * If the connection is starting */ get starting(): boolean; /** * Client connection settings */ get settings(): Settings; /** * Send a message to the server * @param channel The channel to send the message in * @param message The actual message */ send(channel: string, message?: MessageType): void; /** * The error details from WebSocket connection exit */ get exitError(): CloseEvent | null; /** * Listen for server ready events * @param event Event name * @param listener Event callback */ on(event: "ready", listener: () => void): string; /** * Listen for message events from the server * @param event Event name * @param listener Event callback */ on(event: "message", listener: (message: MessageType, channel: string) => void): string; /** * Listen for server ready events * @param event Event name * @param listener Event callback */ once(event: "ready", listener: () => void): string; /** * Listen for message events from the server * @param event Event name * @param listener Event callback */ once(event: "message", listener: (message: MessageType, channel: string) => void): string; }