import { io, Socket } from 'socket.io-client'; /** * Type of handler to catch server events. */ type EventHandler = (data: T, self: InstanceManager) => void | Promise; /** * Type to create object that allows program instance to communicate with the central server. */ declare class InstanceManager { private _socket; private _program_id; private _worker_id; /** * Creates `InstanceManager` instance. * * @param io Socket type from included socket.io library. */ constructor(io: typeof io, server?: string); /** * Socket instance. */ get socket(): Socket; /** * Program id. */ get program_id(): string; /** * Worker id. */ get worker_id(): string; /** * Listens for specific messages from server. * * @param event Event name. * @param handler Callback to handle the event. */ on(event: string, handler: EventHandler): void; /** * Emits a message to server. * * @param event Event name. * @param data Event payload. */ emit(event: string, data: object | null): void; } /** * Exception returned when configuration given to `InstanceManager` constructor is invalid. */ declare class InvalidUrlException extends Error { constructor(message: string); } export { type EventHandler, InstanceManager, InvalidUrlException };