webrtc-signal-http
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -53,3 +53,3 @@ const express = require('express') | ||
// add the peer | ||
const peerId = router.peerList.addPeer(req.query.peer_name, res) | ||
const peerId = router.peerList.addPeer(req.query.peer_name, res, req) | ||
@@ -114,3 +114,3 @@ // send back the list of peers | ||
// using 'push'-ish technology | ||
router.peerList.setPeerSocket(req.query.peer_id, res) | ||
router.peerList.setPeerSocket(req.query.peer_id, res, req) | ||
} | ||
@@ -117,0 +117,0 @@ }) |
@@ -12,3 +12,3 @@ const Emitter = require('events').EventEmitter | ||
addPeer(name, res) { | ||
addPeer(name, res, req) { | ||
this.emit('addPeer:pre', name) | ||
@@ -19,2 +19,3 @@ | ||
peer.res = res | ||
peer.ip = req.ip | ||
@@ -51,5 +52,6 @@ this.emit('addPeer', peer) | ||
setPeerSocket(id, res) { | ||
setPeerSocket(id, res, req) { | ||
if (this._peers[id]) { | ||
this._peers[id].res = res | ||
this._peers[id].ip = req.ip | ||
} | ||
@@ -56,0 +58,0 @@ } |
{ | ||
"name": "webrtc-signal-http", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "opinionated webrtc signal provider using http as a protocol", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,3 +5,3 @@ # webrtc-signal-http | ||
[![Deploy to Azure](https://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/) | ||
[![Deploy to Azure](https://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/) [![Greenkeeper badge](https://badges.greenkeeper.io/bengreenier/webrtc-signal-http.svg)](https://greenkeeper.io/) | ||
@@ -187,3 +187,3 @@ opinionated webrtc signal provider using `http` as a protocol :spider_web: :signal_strength: | ||
[Function] - takes `name` (a string), and `res` (a http.Response object). Creates a representation of the peer for signaling. __Returns__ a `Number` that shall be used as a unique id for the peer. | ||
[Function] - takes `name` (a string), `res` (a http.Response object), and `req` (a http.Request object). Creates a representation of the peer for signaling. __Returns__ a `Number` that shall be used as a unique id for the peer. | ||
@@ -204,3 +204,3 @@ #### removePeer | ||
[Function] - takes `id` (a Number), and `res` (a http.Response object). Updates a representation of the peer with a new response object for signaling. __Returns__ nothing. | ||
[Function] - takes `id` (a Number), `res` (a http.Response object), and `res` (a http.Request object). Updates a representation of the peer with a new response object for signaling. __Returns__ nothing. | ||
@@ -207,0 +207,0 @@ #### pushPeerData |
@@ -93,4 +93,4 @@ const assert = require('assert') | ||
const senderPeerId = app.peerList.addPeer('sendPeer', {}) | ||
const receiverPeerId = app.peerList.addPeer('receivePeer', {}) | ||
const senderPeerId = app.peerList.addPeer('sendPeer', {}, {}) | ||
const receiverPeerId = app.peerList.addPeer('receivePeer', {}, {}) | ||
@@ -115,4 +115,4 @@ const test = request(app) | ||
// simulate adding two peers | ||
const senderPeerId = app.peerList.addPeer('sendPeer', {}) | ||
const receiverPeerId = app.peerList.addPeer('receivePeer', {}) | ||
const senderPeerId = app.peerList.addPeer('sendPeer', {}, {}) | ||
const receiverPeerId = app.peerList.addPeer('receivePeer', {}, {}) | ||
@@ -143,4 +143,4 @@ const test = request(app) | ||
// simulate adding two peers | ||
const firstPeerId = app.peerList.addPeer('firstPeer', {}) | ||
const secondPeerId = app.peerList.addPeer('secondPeer', {}) | ||
const firstPeerId = app.peerList.addPeer('firstPeer', {}, {}) | ||
const secondPeerId = app.peerList.addPeer('secondPeer', {}, {}) | ||
@@ -162,3 +162,3 @@ const test = request(app) | ||
// simulate adding two peers | ||
const firstPeerId = app.peerList.addPeer('firstPeer', {}) | ||
const firstPeerId = app.peerList.addPeer('firstPeer', {}, {}) | ||
@@ -187,4 +187,4 @@ const test = request(app) | ||
// simulate adding two peers | ||
const firstPeerId = app.peerList.addPeer('firstPeer', {}) | ||
const secondPeerId = app.peerList.addPeer('secondPeer', {}) | ||
const firstPeerId = app.peerList.addPeer('firstPeer', {}, {}) | ||
const secondPeerId = app.peerList.addPeer('secondPeer', {}, {}) | ||
@@ -216,3 +216,3 @@ const test = request(app) | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
const peer = instance.getPeer(id) | ||
@@ -233,3 +233,3 @@ | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
@@ -251,3 +251,3 @@ instance.removePeer(id) | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
}) | ||
@@ -263,3 +263,3 @@ | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
}) | ||
@@ -275,3 +275,3 @@ | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
}) | ||
@@ -287,3 +287,3 @@ | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
instance.removePeer(id) | ||
@@ -300,3 +300,3 @@ }) | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
instance.removePeer(id) | ||
@@ -313,3 +313,3 @@ }) | ||
const id = instance.addPeer('test', {obj: true}) | ||
const id = instance.addPeer('test', {obj: true}, {}) | ||
instance.removePeer(id) | ||
@@ -321,10 +321,12 @@ }) | ||
const expectedSocket2 = {obj: false} | ||
const expectedIp = '127.0.0.1' | ||
const instance = new PeerList() | ||
const id = instance.addPeer('test', expectedSocket) | ||
const id = instance.addPeer('test', expectedSocket, {ip: expectedIp}) | ||
const peer = instance.getPeer(id) | ||
assert.equal(peer.res, expectedSocket) | ||
assert.equal(peer.ip, expectedIp) | ||
instance.setPeerSocket(id, expectedSocket2) | ||
instance.setPeerSocket(id, expectedSocket2, {}) | ||
@@ -339,3 +341,3 @@ assert.equal(peer.res, expectedSocket2) | ||
const id = instance.addPeer('test', {}) | ||
const id = instance.addPeer('test', {}, {}) | ||
@@ -353,7 +355,7 @@ assert.equal(instance.popPeerData(id), null) | ||
instance.addPeer('test', {obj: true}) | ||
instance.addPeer('test', {obj: true}, {}) | ||
assert.equal(instance.format(), 'test,1,0\n') | ||
instance.addPeer('test2', {obj: true}) | ||
instance.addPeer('test2', {obj: true}, {}) | ||
@@ -366,7 +368,7 @@ assert.equal(instance.format(), 'test2,2,0\ntest,1,0\n') | ||
instance.addPeer('test', { obj: true }) | ||
instance.addPeer('test', { obj: true }, {}) | ||
assert.equal(instance.dataFor('test'), 'test,1,0\n') | ||
instance.addPeer('test2', { obj: true }) | ||
instance.addPeer('test2', { obj: true }, {}) | ||
@@ -373,0 +375,0 @@ assert.equal(instance.dataFor('test2'), 'test2,2,0\ntest,1,0\n') |
Sorry, the diff of this file is not supported yet
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
2118835
530