@m-onz/cohort-channel

3.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @m-onz/cohort-channel

Weekly Downloads

5

Version

3.0.0

License

none

Unpacked Size

4.5 kB

Total Files

7

Last publish

Collaborators

  • m-onz