import { rpcOnNewSocket } from './rpcService'; export class RpcSocketPool { private rpcSockets: Record = {}; /** * Add socket */ addSocket(id: string, socket: I_RpcSocket) { this.rpcSockets[id] = socket; rpcOnNewSocket(id); } /** * Remove socket */ removeSocket(id: string) { // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete this.rpcSockets[id]; } /** * send messages */ sendMsg(id: string, msg: Buffer) { const socket = this.rpcSockets[id]; if (socket) { socket.send(msg); } } /** * Get socket */ getSocket(id: string) { return this.rpcSockets[id]; } } export interface I_RpcSocket { send(data: Buffer): void; }