webrtc-swarm
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7462
123
70