UNPKG

ipc-network

Version:

Inter-process communication network, allows multiple node process to exchange messages using unix-socket.

30 lines (29 loc) 1.44 kB
/// <reference types="node" /> import { EventEmitter } from "events"; import { UnixDgramSocket } from "unix-dgram-socket"; import { JobItems } from "./JobItems"; export declare class IpcNetwork extends EventEmitter { private rpcCallback?; static readonly ERROR_RPC_SEND = "rpc_send_error"; static readonly ERROR_RPC_TIMEOUT = "rpc_timeout_error"; static readonly ERROR_RPC_EXEC = "rpc_exec_error"; private static readonly TYPE_MESSAGE; private static readonly TYPE_RPC_JOB; private static readonly TYPE_RPC_RESULT; private static readonly TYPE_RPC_ERROR; private static readonly JOB_ID_LENGTH; private static readonly JOB_ID_BUFFER; protected processName: string; protected unixSocketPath: string; protected unixSocket: UnixDgramSocket; protected jobsItems: JobItems; protected uniqBuffer: string[]; constructor(processName?: string, rpcCallback?: ((jobName: string, from: string) => string | Buffer) | undefined); startListening(): void; stopListening(): void; send(data: Buffer | string, socketName: string): boolean; sendRpc(jobName: string, socketName: string, timeout?: number): Promise<Buffer>; protected static composeMessage(messageType: number, messageData: Buffer | string, jobId?: string): Buffer; protected static getSocketPathFromName(socketName: string): string; protected static getSocketNameFromPath(socketPath: string): string; }