UNPKG

lisk-framework

Version:

Lisk blockchain application platform

33 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IPCSocket = void 0; const zeromq_1 = require("zeromq"); const path_1 = require("path"); const fs = require("fs-extra"); class IPCSocket { constructor(options) { this._socketsDir = options.socketsDir; const sockFileName = options.externalSocket ? 'external' : 'internal'; this._eventPubSocketPath = `ipc://${(0, path_1.join)(options.socketsDir, `${sockFileName}.pub.ipc`)}`; this._eventSubSocketPath = `ipc://${(0, path_1.join)(options.socketsDir, `${sockFileName}.sub.ipc`)}`; this._rpcSeverSocketPath = `ipc://${(0, path_1.join)(options.socketsDir, `${options.name}.${sockFileName}.rpc.ipc`)}`; } get rpcServer() { if (!this._rpcServer) { throw new Error('RPC server has not been initialized.'); } return this._rpcServer; } async start() { fs.ensureDirSync(this._socketsDir); this._rpcServer = new zeromq_1.Router(); await this.rpcServer.bind(this._rpcSeverSocketPath); } stop() { this.pubSocket.close(); this.subSocket.close(); this.rpcServer.close(); } } exports.IPCSocket = IPCSocket; //# sourceMappingURL=ipc_socket.js.map