@m-onz/cohort-channel
v3.0.0
Published
p2p channel using webRTC for node & the browser
Downloads
1
Readme
cohort-channel
Create p2p event emitter for collaborative mesh networks and sneakernets in the browser and node.js using WebRTC data channels.
Create a channel
var Cohort = require('@m-onz/cohort-channel')
var cohort = Cohort ({
channel: 'demo-channel',
signalhubs: [ 'http://localhost:9000' ]
})
Reliable event emitter
This is using scuttlebutt/events
cohort.on('demo', console.log)
cohort.emit('demo', 'hello!')
Local signalhub server
You need a local signalhub server for WebRTC signalling and to run the tests.
npm install signalhub -g
signalhub listen -p 9000
npm test
Events
- peers => number of connected peers
- peer => incoming
simple-peer
duplex stream
cohort.on('peers', console.log)
cohort.on('peer', console.log)
Install
npm i @m-onz/cohort-channel