libp2p-signalhub
peer discovery for libp2p using signalhubs
Last updated 2 years ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install libp2p-signalhub 
SYNC missed versions from official npm registry.

libp2p-signalhub

peer discovery for libp2p using signalhubs

Install - Usage - License: Apache-2.0

npm travis standard

Install

npm install libp2p-signalhub

Usage

var Signalhub = require('libp2p-signalhub')

new Libp2p({
  modules: {
    peerDiscovery: [Signalhub]
  },
  config: {
    peerDiscovery: {
      signalhub: {
        appName: 'your-app-name',
        hubs: ['https://signalhub.myapp.org']
      }
    }
  }
})

API

node = new Signalhub(opts)

Create a new peer discover node.

  • opts.appName - required, name of your application, so different apps on one signalhub don't interfere
  • opts.channel - channel name for broadcasts, default 'libp2p-discover'
  • opts.peerInfo - PeerInfo instance, normally passed in by libp2p itself
  • opts.broadcast - whether to broadcast the local multiaddresses to the signalhub, allowing other nodes to find you, default false
  • opts.interval - broadcast interval in ms, default 10 seconds
  • opts.hubs - array of signalhub HTTP URLs to subscribe/broadcast to

node.start(cb)

Start listening for other peers (and broadcasting if opts.broadcast).

cb is called with an error if the subscription could not be started.

node.stop(cb)

Stop listening and broadcasting.

node.on('peer', function(peerInfo))

Event emitted when a new peer is discovered. peerInfo is a PeerInfo instance.

License

Apache-2.0

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |