npm.io
1.0.2 • Published 8 years ago

@clusic/ipc

Licence
MIT
Version
1.0.2
Deps
0
Size
5 kB
Vulns
0
Weekly
0

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 });