0.3.0 • Published 8 years ago
event-swarm v0.3.0
event-swarm
Cross-machine events made simple.
Easily send events across machines on the same network, built using airswarm for network discovery and simple TCP sockets.
Example:
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()
});
Features:
- 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.
Contribute
- Fork it
npm i
gulp watch
- Make changes and write tests.
Send pull request! :sunglasses:
License:
MIT