1.0.2 • Published 6 years ago
@clusic/ipc v1.0.2
IPC channel process controller
IPC 信息通道管理模型。
Install
npm i @clusic/ipc
Usage
const IPC = require('@clusic/ipc');
module.exports = class Master extends IPC {
constructor() {
super();
this.on('message', (msg, socket) => {
// ...
})
}
}
API
ipc.register(name, agent)
const agent = ChildProcess.fork('./agent.js');
const IPC = require('@clusic/ipc');
const ipc = new IPC();
ipc.register('agent', agent);
ipc.send(to, action, body, socket)
const agent = ChildProcess.fork('./agent.js');
const IPC = require('@clusic/ipc');
const ipc = new IPC();
ipc.register('agent', agent);
ipc.send('master', 'test:action', { a: 1, b: 2 });