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

webrtc-swarm

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webrtc-swarm - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

20

index.js

@@ -10,6 +10,8 @@ var SimplePeer = require('simple-peer')

if (!opts) opts = {}
var wrap = opts.wrap || function (data) { return data }
var unwrap = opts.unwrap || function (data) { return data }
var swarm = new events.EventEmitter()
var remotes = {}
var me = cuid()
var me = opts.uuid || cuid()
debug('my uuid:', me)

@@ -42,3 +44,5 @@

sending = true
hub.broadcast(id, {from: me, signal: signals.shift()}, function () {
var data = {from: me, signal: signals.shift()}
data = wrap(data, id)
hub.broadcast(id, data, function () {
sending = false

@@ -59,2 +63,5 @@ kick()

hub.subscribe('all').pipe(through.obj(function (data, enc, cb) {
data = unwrap(data, 'all')
if (!data) return cb()
debug('/all', data)

@@ -76,3 +83,3 @@ if (data.from === me) {

debug('connecting to new peer (as initiator)', data.from )
debug('connecting to new peer (as initiator)', data.from)
var peer = new SimplePeer({

@@ -93,3 +100,5 @@ wrtc: opts.wrtc,

if (swarm.peers.length >= swarm.maxPeers) return
hub.broadcast('all', {type: 'connect', from: me}, function () {
var data = {type: 'connect', from: me}
data = wrap(data, 'all')
hub.broadcast('all', data, function () {
setTimeout(connect, Math.floor(Math.random() * 2000) + (swarm.peers.length ? 13000 : 3000))

@@ -100,2 +109,5 @@ })

hub.subscribe(me).once('open', connect).pipe(through.obj(function (data, enc, cb) {
data = unwrap(data, me)
if (!data) return cb()
var peer = remotes[data.from]

@@ -102,0 +114,0 @@ if (!peer) {

2

package.json
{
"name": "webrtc-swarm",
"version": "2.2.0",
"version": "2.3.0",
"description": "Create a swarm of p2p connections using webrtc and a signalhub",

@@ -5,0 +5,0 @@ "main": "index.js",

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