@arcblock/event-hub
v1.28.1
Published
A nodejs module for local and remote Inter Process Event
Readme
Event Hub
A module for local and remote Inter Process Event
Usage
Install
pnpm install @arcblock/event-hubServer
process.env.ABT_NODE_EVENT_PORT=8888;
require('@arcblock/event-hub/lib/server.js);Client
// process 1
const Client = require('@arcblock/event-hub/lib/client');
const port = ''; // event-hub server port
const did = ''; // your did
const sk = ''; // your sk
const client = new Client({ port, did, sk, autoConnect: true });
const data = { foo: bar };
client.broadcast('my-event', data);// process 2
const Client = require('@arcblock/event-hub/lib/client');
const port = ''; // event-hub server port
const did = ''; // your did
const sk = ''; // your sk
const client = new Client({ port, did, sk, autoConnect: true });
client.on('my-event', (data) => {
// handle data
});