Skip to content

Commit

Permalink
Merge remote-tracking branch 'feross/master' into destroy-on-connecti…
Browse files Browse the repository at this point in the history
…on-fail

# Conflicts:
#	simplepeer.min.js
  • Loading branch information
t-mullen committed Sep 26, 2019
2 parents 103293b + eaad81b commit 4d8f90e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var debug = require('debug')('simple-peer')
var getBrowserRTC = require('get-browser-rtc')
var randombytes = require('randombytes')
var stream = require('readable-stream')
var queueMicrotask = require('queue-microtask') // TODO: remove when Node 10 is not supported

var MAX_BUFFERED_AMOUNT = 64 * 1024
var ICECOMPLETE_TIMEOUT = 5 * 1000
Expand Down Expand Up @@ -100,7 +101,7 @@ class Peer extends stream.Duplex {
try {
this._pc = new (this._wrtc.RTCPeerConnection)(this.config)
} catch (err) {
setTimeout(() => this.destroy(makeError(err, 'ERR_PC_CONSTRUCTOR')), 0)
queueMicrotask(() => this.destroy(makeError(err, 'ERR_PC_CONSTRUCTOR')))
return
}

Expand Down Expand Up @@ -361,11 +362,11 @@ class Peer extends stream.Duplex {
this._debug('_needsNegotiation')
if (this._batchedNegotiation) return // batch synchronous renegotiations
this._batchedNegotiation = true
setTimeout(() => {
queueMicrotask(() => {
this._batchedNegotiation = false
this._debug('starting batched negotiation')
this.negotiate()
}, 0)
})
}

negotiate () {
Expand Down Expand Up @@ -975,9 +976,9 @@ class Peer extends stream.Duplex {
})) return // Only fire one 'stream' event, even though there may be multiple tracks per stream

this._remoteStreams.push(eventStream)
setTimeout(() => {
queueMicrotask(() => {
this.emit('stream', eventStream) // ensure all tracks have been added
}, 0)
})
})
}

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "simple-peer",
"description": "Simple one-to-one WebRTC video/voice and data channels",
"version": "9.5.0",
"version": "9.6.0",
"author": {
"name": "Feross Aboukhadijeh",
"email": "[email protected]",
Expand All @@ -13,6 +13,7 @@
"dependencies": {
"debug": "^4.0.1",
"get-browser-rtc": "^1.0.0",
"queue-microtask": "^1.1.0",
"randombytes": "^2.0.3",
"readable-stream": "^3.4.0"
},
Expand Down
6 changes: 6 additions & 0 deletions simplepeer.min.js

Large diffs are not rendered by default.

0 comments on commit 4d8f90e

Please sign in to comment.