Socket
Socket
Sign inDemoInstall

hybrid-swarm

Package Overview
Dependencies
136
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hybrid-swarm

Finds peers using client-side browser webrtc connections and node.js


Version published
Weekly downloads
9
increased by800%
Maintainers
6
Install size
7.07 MB
Created
Weekly downloads
 

Readme

Source

hybrid-swarm

Finds peers using client-side browser webrtc connections and node.js.

Usage

var hybrid = require('hybrid-swarm')


// see npmjs.org/webrtc-swarm
var signalhub = 'https://signalhub.mafintosh.com'

// see npmjs.org/discovery-swarm
var discovery = { ... }

var swarm = hybrid({
  signalhub: signalhub,
  discovery: discovery
})

swarm.on('connection', function (conn) {
  if (conn.type === 'webrtc-swarm') {
    console.log('connected to webrtc-swarm')
  }
  if (conn.type === 'discovery-swarm') {
    console.log('connected to discovery swarm')
  }
  console.log(swarm.hybrid.connections, 'total connections')
})

API

HybridSwarm(opts)

Takes options for signalhub and discovery. See example for more information.

HybridSwarm.connections

The number of total connections.

HybridSwarm._connection(conn, opts)

Called when the swarm has found a new connection (or peer).

Arguments:

  • conn: connection object
  • opts: contains metadata, such as the module/connection type: 'webrtc-swarm' or 'discovery-swarm'
HybridSwarm._listening()

Called when the node swarm is listening.

Example

Used in

  • hyperdrive-archive-swarm

Keywords

FAQs

Last updated on 12 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc