@m-onz/cohort
v6.0.0
Published
connected
Downloads
6
Readme
cohort
p2p discovery layer, identity and messaging for node.js & the browser
Events
message
var cohort = require('@m-onz/cohort')
var Peer = cohort('demo')
Peer.on('message', function (message) {
console.log(Peer.peerID, '> ', message)
})
Pass in identity
var cid = require('@m-onz/cohort-id')
var Peer = cohort('demo', cid.id)
var Peer = cohort('demo', {
publicKey: '',
secretKey: '',
boxPublicKey: '',
boxSecretKey: ''
})
Peer.on('message', function (message) {
console.log(Peer.peerID, '> ', message)
})
Methods
connected
Peer.connected(function (e, peers) {
console.log(peers)
})
send
Peer.send('peerID', 'hello peer!')
broadcast
Peer.broadcast('hello world!')
Install
npm i @m-onz/cohort