Skip to content

Commit

Permalink
handle renegotiation with streams correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mullen committed Jan 6, 2019
1 parent 24adb50 commit 9b33e99
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-signal-client",
"version": "2.0.0",
"version": "2.0.1",
"description": "socket.io signalling solution for simple-peer",
"main": "src/index.js",
"author": "Thomas Mullen",
Expand Down
4 changes: 3 additions & 1 deletion client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ SimpleSignalClient.prototype.connect = function (target, metadata = {}, peerOpti
peerOptions.initiator = true

const sessionId = cuid() // TODO: Use crypto
var firstOffer = true
const peer = this._peers[sessionId] = new SimplePeer(peerOptions)

peer.on('close', () => {
Expand All @@ -88,7 +89,8 @@ SimpleSignalClient.prototype.connect = function (target, metadata = {}, peerOpti
})

peer.on('signal', (signal) => {
const messageType = signal.sdp ? 'simple-signal[offer]' : 'simple-signal[signal]'
const messageType = signal.sdp && firstOffer ? 'simple-signal[offer]' : 'simple-signal[signal]'
if (signal.sdp) firstOffer = false
this.socket.emit(messageType, {
signal, metadata, sessionId, target
})
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-signal-server",
"version": "2.0.0",
"version": "2.0.1",
"description": "socket.io signalling solution for simple-peer",
"main": "src/index.js",
"author": "Thomas Mullen",
Expand Down

0 comments on commit 9b33e99

Please sign in to comment.