a p2p event emitter
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
.gitignore
README.md
example.js
index.js
package.json

README.md

Peer Events

A p2p EventEmitter. Listen for and emit events on a swarm.

npm install peer-events

Usage

var PeerEmitter = require('peer-events')

var peer = new PeerEmitter()

// listen for events from peers on swarm
peer.on('message', (message) => console.log(message))

// emit event to peers on swarm
peer.emit('message', 'hello world')

API

var peer = new PeerEmitter()

Create a new instance. The returned object is a duplex stream.

peer.open(key)

Begin looking for and connecting to peers on the channel key.

peer.emit(key, data)

Emit event to all peers listening on key.

peer.on(key, callback)

Listen for events on key.