Cross-machine events made simple.
Easily send events across machines on the same network, built using airswarm for network discovery and simple TCP sockets.
import EventSwarm from 'event-swarm';
// On first machine...
let swarm = new EventSwarm({ channel: 'chat' });
swarm.on('ping', e => {
// e.sender is the id of the sender.
// e.data is the payload of the message (automatically (de)serialized).
// e.event is the event name.
// e.created is the millisecond timestamp of when the source created it.
console.log('pong', e.data);
});
// On second machine...
let swarm = new EventSwarm({ channel: 'chat' });
swarm.emit('ping', {
string: 'Hello!',
num: 10,
date: new Date()
});
- Built on airswarm.
- Channels allow for multiple swarms to exist on the same network.
- Built-in events for connection and disconnection.
- Broadcast events or send events to specific peers.
- Fork it
npm i
gulp watch
- Make changes and write tests.
- Send pull request! 😎
MIT