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.4.0 to 2.5.0

7

index.js

@@ -12,2 +12,3 @@ var SimplePeer = require('simple-peer')

var unwrap = opts.unwrap || function (data) { return data }
var offerConstraints = opts.offerConstraints || {}

@@ -85,3 +86,4 @@ var swarm = new events.EventEmitter()

initiator: true,
config: opts.config
config: opts.config,
offerConstraints: offerConstraints
})

@@ -119,3 +121,4 @@

wrtc: opts.wrtc,
config: opts.config
config: opts.config,
offerConstraints: offerConstraints
})

@@ -122,0 +125,0 @@

{
"name": "webrtc-swarm",
"version": "2.4.0",
"version": "2.5.0",
"description": "Create a swarm of p2p connections using webrtc and a signalhub",

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

# webrtc-swarm
Create a swarm of p2p connections using webrtc and a signalhub
> Create a swarm of p2p connections using webrtc and a
[signalhub](https://github.com/mafintosh/signalhub).

@@ -14,3 +15,2 @@ ```

var signalhub = require('signalhub')
var wrtc = require('wrtc')

@@ -20,3 +20,3 @@ var hub = signalhub('swarm-example', ['http://yourdomain.com'])

var sw = swarm(hub, {
wrtc: wrtc // you don't need this if you use it in the browser
wrtc: require('wrtc') // don't need this if used in the browser
})

@@ -28,6 +28,45 @@

})
sw.on('disconnect', function (peer, id) {
console.log('disconnected from a peer:', id)
console.log('total peers:', sw.peers.length)
})
```
## API
```js
var swarm = require('webrtc-swarm')
```
### var sw = swarm(hub, opts)
Creates a new webrtc swarm using
[signalhub](https://github.com/mafintosh/signalhub) `hub` for discovery and
connection brokering.
Valid keys for `opts` include
- `wrtc` - (optional) a reference to the `wrtc` library, if using Node.
- `uuid` - (optional) a unique identifier for this peer. One is generated for you
if not supplied.
- `maxPeers` - (optional) the maximum number of peers you wish to connect to.
Defaults to unlimited.
### sw.on('peer|connect', peer, id)
`peer` and `connect` are interchangeable. Fires when a connection has been
established to a new peer `peer`, with unique id `id`.
### sw.on('disconnect', peer, id)
Fires when an existing peer connection is lost.
### sw.peers
A list of peers that `sw` is currently connected to.
## License
MIT
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