Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hybrid-swarm

Package Overview
Dependencies
Maintainers
6
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hybrid-swarm

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

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
6
Created
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

Package last updated on 12 Sep 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc