IPC 信息通道管理模型。
npm i @clusic/ipc
const IPC = require('@clusic/ipc');
module.exports = class Master extends IPC {
constructor() {
super();
this.on('message', (msg, socket) => {
// ...
})
}
}
const agent = ChildProcess.fork('./agent.js');
const IPC = require('@clusic/ipc');
const ipc = new IPC();
ipc.register('agent', agent);
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 });