event-swarm

0.3.0 • Public • Published

event-swarm

Cross-machine events made simple.

Build Status Code Coverage Dependencies DevDependencies npm Monthly Downloads Total Downloads

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

  1. Fork it
  2. npm i
  3. gulp watch
  4. Make changes and write tests.
  5. Send pull request! 😎

License:

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i event-swarm

Weekly Downloads

2

Version

0.3.0

License

MIT

Last publish

Collaborators

  • jimbuck