osmia-consent-swarm

1.0.1 • Public • Published

consent-swarm

discovery-swarm with two-way replication consent

npm install consent-swarm

build status

Usage

var swarm = require('consent-swarm')
 
var sw = swarm()
 
sw.listen(1000)
sw.join('ubuntu-14.04') // can be any id/name/hash
 
sw.on('connection', function (connection) {
  // here the client can send some data that might help the user
  // make a decision if they want to continue the connection
  // or only replicate parts of the data
  connection.request({message: 'im-cool'})
 
  connection.on('request', function (data) {
    if (data.message === 'im-cool') {
      connection.accept({message: 'ok sure'})
    } else {
      connection.reject({message: 'nope'})
    }
  })
 
  connection.on('reject', function (data) {
    console.log('rejected! reason:', data.message)
  })
 
  connection.on('accept', function (data) {
    connection.write('some more stuff now, thanks for the consent buddy\n')
  })
 
  console.log('found + connected to peer')
})
 
sw.on('error', function (err) {
  console.error(err)
})

Package Sidebar

Install

npm i osmia-consent-swarm

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

5.87 kB

Total Files

4

Last publish

Collaborators

  • parweb