Node.js port of Zyre - an open-source framework for proximity-based peer-to-peer applications
This project is currently in development and not considered stable yet.
npm install zyre.js
A jsdoc documentation can be found here.
There is a sample chat package, that can be found here.
Inline example of two nodes talking to each other:
const zyre = require('zyre.js');
const z1 = zyre.new({ name: 'z1' });
const z2 = zyre.new({ name: 'z2' });
z1.on('shout', (id, name, message, group) => {
console.log(`#${group} <${name}> ${message}`);
});
z2.on('shout', (id, name, message, group) => {
console.log(`#${group} <${name}> ${message}`);
z2.shout('CHAT', 'Hey!');
});
z1.start().then(() => {
z1.join('CHAT');
z2.start().then(() => {
z2.join('CHAT');
});
});
setInterval(() => {
z1.shout('CHAT', 'Hello World!');
}, 1000);