@sallar-network/server
v1.0.3
Published
Server-side library for manage and communicate with programs running on the sallar network
Readme
@sallar-network/server
Description
Server-side library for manage and communicate with programs running on the sallar network.
Installation
$ npm i @sallar-network/serverDocs
$ npm run generate-docsBuild
You can build and test the library on your own:
$ npm run buildAnd add to your project:
$ npm link
$ npm link @sallar-network/serverExample
import { InstanceManager } from '@sallar-network/server';
const manager = new InstanceManager({
public_path: `./public`, // Your program files
http_port: 3000, // Your server port
dev_mode: true, // To test locally
// For production:
node_manager_server: process.env.node_manager_server,
program_token: process.env.program_token
});
// Listen for program event
manager.on('hello', ({ worker_id }) => {
console.log(`${worker_id} said hello!`);
});
await manager.launch(({ worker_id }, manager) => {
// Send events to program
manager.emit('say-hello', null, worker_id);
});