From e55dba8e6cebe919333e623ece4aa9ba92569561 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 17 Mar 2021 18:38:09 -0700 Subject: [PATCH 1/7] 9.10.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 740778d3..eee1c5c4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "simple-peer", "description": "Simple one-to-one WebRTC video/voice and data channels", - "version": "9.9.4", + "version": "9.10.0", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", From bde2bb51fcbae9d322e70a53b0f4d72366e4ca54 Mon Sep 17 00:00:00 2001 From: Zachary Hueras Date: Sun, 13 Dec 2020 01:31:50 -0500 Subject: [PATCH 2/7] lsp-format-buffer --- index.js | 112 +++++++++++++++++++++++-------------------------------- 1 file changed, 47 insertions(+), 65 deletions(-) diff --git a/index.js b/index.js index b715fb6f..aefd186f 100644 --- a/index.js +++ b/index.js @@ -12,11 +12,11 @@ const ICECOMPLETE_TIMEOUT = 5 * 1000 const CHANNEL_CLOSING_TIMEOUT = 5 * 1000 // HACK: Filter trickle lines when trickle is disabled #354 -function filterTrickle (sdp) { +function filterTrickle(sdp) { return sdp.replace(/a=ice-options:trickle\s\n/g, '') } -function warn (message) { +function warn(message) { console.warn(message) } @@ -26,7 +26,7 @@ function warn (message) { * @param {Object} opts */ class Peer extends stream.Duplex { - constructor (opts) { + constructor(opts) { opts = Object.assign({ allowHalfOpen: false }, opts) @@ -165,23 +165,22 @@ class Peer extends stream.Duplex { this.once('finish', this._onFinishBound) } - get bufferSize () { + get bufferSize() { return (this._channel && this._channel.bufferedAmount) || 0 } // HACK: it's possible channel.readyState is "closing" before peer.destroy() fires // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 - get connected () { + get connected() { return (this._connected && this._channel.readyState === 'open') } - address () { + address() { return { port: this.localPort, family: this.localFamily, address: this.localAddress } } - signal (data) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_DESTROYED') + signal(data) { + if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_SIGNALING') if (typeof data === 'string') { try { data = JSON.parse(data) @@ -227,7 +226,7 @@ class Peer extends stream.Duplex { } } - _addIceCandidate (candidate) { + _addIceCandidate(candidate) { const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate) this._pc.addIceCandidate(iceCandidateObj) .catch(err => { @@ -243,9 +242,7 @@ class Peer extends stream.Duplex { * Send text/binary data to the remote peer. * @param {ArrayBufferView|ArrayBuffer|Buffer|string|Blob} chunk */ - send (chunk) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot send after peer is destroyed'), 'ERR_DESTROYED') + send(chunk) { this._channel.send(chunk) } @@ -254,9 +251,7 @@ class Peer extends stream.Duplex { * @param {String} kind * @param {Object} init */ - addTransceiver (kind, init) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot addTransceiver after peer is destroyed'), 'ERR_DESTROYED') + addTransceiver(kind, init) { this._debug('addTransceiver()') if (this.initiator) { @@ -278,9 +273,7 @@ class Peer extends stream.Duplex { * Add a MediaStream to the connection. * @param {MediaStream} stream */ - addStream (stream) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot addStream after peer is destroyed'), 'ERR_DESTROYED') + addStream(stream) { this._debug('addStream()') stream.getTracks().forEach(track => { @@ -293,9 +286,7 @@ class Peer extends stream.Duplex { * @param {MediaStreamTrack} track * @param {MediaStream} stream */ - addTrack (track, stream) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot addTrack after peer is destroyed'), 'ERR_DESTROYED') + addTrack(track, stream) { this._debug('addTrack()') const submap = this._senderMap.get(track) || new Map() // nested Maps map [track, stream] to sender @@ -318,9 +309,7 @@ class Peer extends stream.Duplex { * @param {MediaStreamTrack} newTrack * @param {MediaStream} stream */ - replaceTrack (oldTrack, newTrack, stream) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot replaceTrack after peer is destroyed'), 'ERR_DESTROYED') + replaceTrack(oldTrack, newTrack, stream) { this._debug('replaceTrack()') const submap = this._senderMap.get(oldTrack) @@ -342,9 +331,7 @@ class Peer extends stream.Duplex { * @param {MediaStreamTrack} track * @param {MediaStream} stream */ - removeTrack (track, stream) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot removeTrack after peer is destroyed'), 'ERR_DESTROYED') + removeTrack(track, stream) { this._debug('removeSender()') const submap = this._senderMap.get(track) @@ -369,9 +356,7 @@ class Peer extends stream.Duplex { * Remove a MediaStream from the connection. * @param {MediaStream} stream */ - removeStream (stream) { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot removeStream after peer is destroyed'), 'ERR_DESTROYED') + removeStream(stream) { this._debug('removeSenders()') stream.getTracks().forEach(track => { @@ -379,7 +364,7 @@ class Peer extends stream.Duplex { }) } - _needsNegotiation () { + _needsNegotiation() { this._debug('_needsNegotiation') if (this._batchedNegotiation) return // batch synchronous renegotiations this._batchedNegotiation = true @@ -395,10 +380,7 @@ class Peer extends stream.Duplex { }) } - negotiate () { - if (this.destroying) return - if (this.destroyed) throw errCode(new Error('cannot negotiate after peer is destroyed'), 'ERR_DESTROYED') - + negotiate() { if (this.initiator) { if (this._isNegotiating) { this._queuedNegotiation = true @@ -427,11 +409,11 @@ class Peer extends stream.Duplex { // TODO: Delete this method once readable-stream is updated to contain a default // implementation of destroy() that automatically calls _destroy() // See: https://github.com/nodejs/readable-stream/issues/283 - destroy (err) { - this._destroy(err, () => {}) + destroy(err) { + this._destroy(err, () => { }) } - _destroy (err, cb) { + _destroy(err, cb) { if (this.destroyed || this.destroying) return this.destroying = true @@ -469,7 +451,7 @@ class Peer extends stream.Duplex { if (this._channel) { try { this._channel.close() - } catch (err) {} + } catch (err) { } // allow events concurrent with destruction to be handled this._channel.onmessage = null @@ -480,7 +462,7 @@ class Peer extends stream.Duplex { if (this._pc) { try { this._pc.close() - } catch (err) {} + } catch (err) { } // allow events concurrent with destruction to be handled this._pc.oniceconnectionstatechange = null @@ -499,7 +481,7 @@ class Peer extends stream.Duplex { }) } - _setupData (event) { + _setupData(event) { if (!event.channel) { // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc), // which is invalid behavior. Handle it gracefully. @@ -545,9 +527,9 @@ class Peer extends stream.Duplex { }, CHANNEL_CLOSING_TIMEOUT) } - _read () {} + _read() { } - _write (chunk, encoding, cb) { + _write(chunk, encoding, cb) { if (this.destroyed) return cb(errCode(new Error('cannot write after peer is destroyed'), 'ERR_DATA_CHANNEL')) if (this._connected) { @@ -571,7 +553,7 @@ class Peer extends stream.Duplex { // When stream finishes writing, close socket. Half open connections are not // supported. - _onFinish () { + _onFinish() { if (this.destroyed) return // Wait a bit before destroying so the socket flushes. @@ -587,7 +569,7 @@ class Peer extends stream.Duplex { } } - _startIceCompleteTimeout () { + _startIceCompleteTimeout() { if (this.destroyed) return if (this._iceCompleteTimer) return this._debug('started iceComplete timeout') @@ -601,7 +583,7 @@ class Peer extends stream.Duplex { }, this.iceCompleteTimeout) } - _createOffer () { + _createOffer() { if (this.destroyed) return this._pc.createOffer(this.offerOptions) @@ -640,7 +622,7 @@ class Peer extends stream.Duplex { }) } - _requestMissingTransceivers () { + _requestMissingTransceivers() { if (this._pc.getTransceivers) { this._pc.getTransceivers().forEach(transceiver => { if (!transceiver.mid && transceiver.sender.track && !transceiver.requested) { @@ -651,7 +633,7 @@ class Peer extends stream.Duplex { } } - _createAnswer () { + _createAnswer() { if (this.destroyed) return this._pc.createAnswer(this.answerOptions) @@ -690,14 +672,14 @@ class Peer extends stream.Duplex { }) } - _onConnectionStateChange () { + _onConnectionStateChange() { if (this.destroyed) return if (this._pc.connectionState === 'failed') { this.destroy(errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE')) } } - _onIceStateChange () { + _onIceStateChange() { if (this.destroyed) return const iceConnectionState = this._pc.iceConnectionState const iceGatheringState = this._pc.iceGatheringState @@ -721,7 +703,7 @@ class Peer extends stream.Duplex { } } - getStats (cb) { + getStats(cb) { // statreports can come with a value array instead of properties const flattenValues = report => { if (Object.prototype.toString.call(report.values) === '[object Array]') { @@ -743,7 +725,7 @@ class Peer extends stream.Duplex { cb(null, reports) }, err => cb(err)) - // Single-parameter callback-based getStats() (non-standard) + // Single-parameter callback-based getStats() (non-standard) } else if (this._pc.getStats.length > 0) { this._pc.getStats(res => { // If we destroy connection in `connect` callback this code might happen to run when actual connection is already closed @@ -763,14 +745,14 @@ class Peer extends stream.Duplex { cb(null, reports) }, err => cb(err)) - // Unknown browser, skip getStats() since it's anyone's guess which style of - // getStats() they implement. + // Unknown browser, skip getStats() since it's anyone's guess which style of + // getStats() they implement. } else { cb(null, []) } } - _maybeReady () { + _maybeReady() { this._debug('maybeReady pc %s channel %s', this._pcReady, this._channelReady) if (this._connected || this._connecting || !this._pcReady || !this._channelReady) return @@ -910,14 +892,14 @@ class Peer extends stream.Duplex { findCandidatePair() } - _onInterval () { + _onInterval() { if (!this._cb || !this._channel || this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) { return } this._onChannelBufferedAmountLow() } - _onSignalingStateChange () { + _onSignalingStateChange() { if (this.destroyed) return if (this._pc.signalingState === 'stable') { @@ -945,7 +927,7 @@ class Peer extends stream.Duplex { this.emit('signalingStateChange', this._pc.signalingState) } - _onIceCandidate (event) { + _onIceCandidate(event) { if (this.destroyed) return if (event.candidate && this.trickle) { this.emit('signal', { @@ -966,14 +948,14 @@ class Peer extends stream.Duplex { } } - _onChannelMessage (event) { + _onChannelMessage(event) { if (this.destroyed) return let data = event.data if (data instanceof ArrayBuffer) data = Buffer.from(data) this.push(data) } - _onChannelBufferedAmountLow () { + _onChannelBufferedAmountLow() { if (this.destroyed || !this._cb) return this._debug('ending backpressure: bufferedAmount %d', this._channel.bufferedAmount) const cb = this._cb @@ -981,20 +963,20 @@ class Peer extends stream.Duplex { cb(null) } - _onChannelOpen () { + _onChannelOpen() { if (this._connected || this.destroyed) return this._debug('on channel open') this._channelReady = true this._maybeReady() } - _onChannelClose () { + _onChannelClose() { if (this.destroyed) return this._debug('on channel close') this.destroy() } - _onTrack (event) { + _onTrack(event) { if (this.destroyed) return event.streams.forEach(eventStream => { @@ -1018,7 +1000,7 @@ class Peer extends stream.Duplex { }) } - _debug () { + _debug() { const args = [].slice.call(arguments) args[0] = '[' + this._id + '] ' + args[0] debug.apply(null, args) From 8730012e9142094912499a0bc1497f2acb32da63 Mon Sep 17 00:00:00 2001 From: Zachary Hueras Date: Mon, 14 Dec 2020 03:48:51 -0500 Subject: [PATCH 3/7] Listen to iceGatheringState for completed --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index aefd186f..9c6cbc0a 100644 --- a/index.js +++ b/index.js @@ -691,7 +691,7 @@ class Peer extends stream.Duplex { ) this.emit('iceStateChange', iceConnectionState, iceGatheringState) - if (iceConnectionState === 'connected' || iceConnectionState === 'completed') { + if (iceConnectionState === 'connected' || iceGatheringState === 'completed') { this._pcReady = true this._maybeReady() } From 9a9c6662cef513716f4a0394257d5d680bd79744 Mon Sep 17 00:00:00 2001 From: Zachary Hueras Date: Mon, 14 Dec 2020 03:54:25 -0500 Subject: [PATCH 4/7] Attempt to support manual ice restarts --- index.js | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 9c6cbc0a..4dadd112 100644 --- a/index.js +++ b/index.js @@ -51,6 +51,7 @@ class Peer extends stream.Duplex { this.trickle = opts.trickle !== undefined ? opts.trickle : true this.allowHalfTrickle = opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT + this.iceRestartEnabled = 'iceRestartEnabled' in opts ? opts.iceRestartEnabled : true this.destroyed = false this.destroying = false @@ -380,7 +381,7 @@ class Peer extends stream.Duplex { }) } - negotiate() { + negotiate (restart = false) { if (this.initiator) { if (this._isNegotiating) { this._queuedNegotiation = true @@ -388,9 +389,10 @@ class Peer extends stream.Duplex { } else { this._debug('start negotiation') setTimeout(() => { // HACK: Chrome crashes if we immediately call createOffer - this._createOffer() + this._createOffer(restart) }, 0) } + this._isRestarting = restart } else { if (this._isNegotiating) { this._queuedNegotiation = true @@ -406,6 +408,16 @@ class Peer extends stream.Duplex { this._isNegotiating = true } + restart () { + if (this.initiator) { + if (this._isRestarting) { + this._debug('already restarting, ignoring') + } else { + this._pc.restartIce(); + } + } + } + // TODO: Delete this method once readable-stream is updated to contain a default // implementation of destroy() that automatically calls _destroy() // See: https://github.com/nodejs/readable-stream/issues/283 @@ -674,8 +686,10 @@ class Peer extends stream.Duplex { _onConnectionStateChange() { if (this.destroyed) return - if (this._pc.connectionState === 'failed') { + if (this._pc.connectionState === 'failed' && !this.iceRestartEnabled) { this.destroy(errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE')) + } else if (this._pc.connectionState === 'failed' && this.iceRestartEnabled) { + this._pc.restartIce() } } @@ -692,10 +706,19 @@ class Peer extends stream.Duplex { this.emit('iceStateChange', iceConnectionState, iceGatheringState) if (iceConnectionState === 'connected' || iceGatheringState === 'completed') { + this._isRestarting = false this._pcReady = true this._maybeReady() } - if (iceConnectionState === 'failed') { + + if (iceConnectionState === 'failed' && this.iceRestartEnabled) { + if (this.initiator && !this._isRestarting) { + this._isNegotiating = false + this._isRestarting = true + + this._needsNegotiation(true) + } + } else if (iceConnectionState === 'failed' && !this.iceRestartEnabled) { this.destroy(errCode(new Error('Ice connection failed.'), 'ERR_ICE_CONNECTION_FAILURE')) } if (iceConnectionState === 'closed') { @@ -752,9 +775,9 @@ class Peer extends stream.Duplex { } } - _maybeReady() { + _maybeReady () { this._debug('maybeReady pc %s channel %s', this._pcReady, this._channelReady) - if (this._connected || this._connecting || !this._pcReady || !this._channelReady) return + if (((this._connected || this._connecting) && !this._isRestarting) || !this._pcReady || !this._channelReady) return this._connecting = true From 0f96a000b3e9952e4522fa6b10128c1ebf5d2816 Mon Sep 17 00:00:00 2001 From: Zachary Hueras Date: Mon, 14 Dec 2020 04:01:20 -0500 Subject: [PATCH 5/7] Basic test case for ICE restarts that still fails --- test/negotiation.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/negotiation.js b/test/negotiation.js index a6c4a879..5b16add5 100644 --- a/test/negotiation.js +++ b/test/negotiation.js @@ -204,3 +204,38 @@ test('negotiated channels', function (t) { t.pass('peer2 connect') }) }) + +test('renegotiation after restart', function (t) { + t.plan(4) + + const peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc }) + const peer2 = new Peer({ config, wrtc: common.wrtc }) + + peer1.on('signal', function (data) { + if (!peer2.destroyed) peer2.signal(data) + }) + peer2.on('signal', function (data) { + if (!peer1.destroyed) peer1.signal(data) + }) + + peer1.on('connect', function () { + peer1.addStream(common.getMediaStream()) + }) + peer2.on('connect', function () { + peer2.addStream(common.getMediaStream()) + }) + + peer1.on('stream', function () { + t.pass('got peer1 stream') + }) + + peer2.on('stream', function () { + t.pass('got peer2 stream') + peer1.restart() + }) + + let tracks = 1 + peer2.on('track', function () { + t.pass(`got peer2 track ${tracks++}`) + }) +}) From 67e1cc38bed6f6b3a4cb91c9913527cce3c3c248 Mon Sep 17 00:00:00 2001 From: Zachary Hueras Date: Mon, 14 Dec 2020 13:08:42 -0500 Subject: [PATCH 6/7] Run standard --fix --- index.js | 78 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/index.js b/index.js index 4dadd112..320b21dc 100644 --- a/index.js +++ b/index.js @@ -12,11 +12,11 @@ const ICECOMPLETE_TIMEOUT = 5 * 1000 const CHANNEL_CLOSING_TIMEOUT = 5 * 1000 // HACK: Filter trickle lines when trickle is disabled #354 -function filterTrickle(sdp) { +function filterTrickle (sdp) { return sdp.replace(/a=ice-options:trickle\s\n/g, '') } -function warn(message) { +function warn (message) { console.warn(message) } @@ -26,7 +26,7 @@ function warn(message) { * @param {Object} opts */ class Peer extends stream.Duplex { - constructor(opts) { + constructor (opts) { opts = Object.assign({ allowHalfOpen: false }, opts) @@ -166,21 +166,21 @@ class Peer extends stream.Duplex { this.once('finish', this._onFinishBound) } - get bufferSize() { + get bufferSize () { return (this._channel && this._channel.bufferedAmount) || 0 } // HACK: it's possible channel.readyState is "closing" before peer.destroy() fires // https://bugs.chromium.org/p/chromium/issues/detail?id=882743 - get connected() { + get connected () { return (this._connected && this._channel.readyState === 'open') } - address() { + address () { return { port: this.localPort, family: this.localFamily, address: this.localAddress } } - signal(data) { + signal (data) { if (this.destroyed) throw errCode(new Error('cannot signal after peer is destroyed'), 'ERR_SIGNALING') if (typeof data === 'string') { try { @@ -227,7 +227,7 @@ class Peer extends stream.Duplex { } } - _addIceCandidate(candidate) { + _addIceCandidate (candidate) { const iceCandidateObj = new this._wrtc.RTCIceCandidate(candidate) this._pc.addIceCandidate(iceCandidateObj) .catch(err => { @@ -243,7 +243,7 @@ class Peer extends stream.Duplex { * Send text/binary data to the remote peer. * @param {ArrayBufferView|ArrayBuffer|Buffer|string|Blob} chunk */ - send(chunk) { + send (chunk) { this._channel.send(chunk) } @@ -252,7 +252,7 @@ class Peer extends stream.Duplex { * @param {String} kind * @param {Object} init */ - addTransceiver(kind, init) { + addTransceiver (kind, init) { this._debug('addTransceiver()') if (this.initiator) { @@ -274,7 +274,7 @@ class Peer extends stream.Duplex { * Add a MediaStream to the connection. * @param {MediaStream} stream */ - addStream(stream) { + addStream (stream) { this._debug('addStream()') stream.getTracks().forEach(track => { @@ -287,7 +287,7 @@ class Peer extends stream.Duplex { * @param {MediaStreamTrack} track * @param {MediaStream} stream */ - addTrack(track, stream) { + addTrack (track, stream) { this._debug('addTrack()') const submap = this._senderMap.get(track) || new Map() // nested Maps map [track, stream] to sender @@ -310,7 +310,7 @@ class Peer extends stream.Duplex { * @param {MediaStreamTrack} newTrack * @param {MediaStream} stream */ - replaceTrack(oldTrack, newTrack, stream) { + replaceTrack (oldTrack, newTrack, stream) { this._debug('replaceTrack()') const submap = this._senderMap.get(oldTrack) @@ -332,7 +332,7 @@ class Peer extends stream.Duplex { * @param {MediaStreamTrack} track * @param {MediaStream} stream */ - removeTrack(track, stream) { + removeTrack (track, stream) { this._debug('removeSender()') const submap = this._senderMap.get(track) @@ -357,7 +357,7 @@ class Peer extends stream.Duplex { * Remove a MediaStream from the connection. * @param {MediaStream} stream */ - removeStream(stream) { + removeStream (stream) { this._debug('removeSenders()') stream.getTracks().forEach(track => { @@ -365,7 +365,7 @@ class Peer extends stream.Duplex { }) } - _needsNegotiation() { + _needsNegotiation () { this._debug('_needsNegotiation') if (this._batchedNegotiation) return // batch synchronous renegotiations this._batchedNegotiation = true @@ -413,7 +413,7 @@ class Peer extends stream.Duplex { if (this._isRestarting) { this._debug('already restarting, ignoring') } else { - this._pc.restartIce(); + this._pc.restartIce() } } } @@ -421,11 +421,11 @@ class Peer extends stream.Duplex { // TODO: Delete this method once readable-stream is updated to contain a default // implementation of destroy() that automatically calls _destroy() // See: https://github.com/nodejs/readable-stream/issues/283 - destroy(err) { + destroy (err) { this._destroy(err, () => { }) } - _destroy(err, cb) { + _destroy (err, cb) { if (this.destroyed || this.destroying) return this.destroying = true @@ -493,7 +493,7 @@ class Peer extends stream.Duplex { }) } - _setupData(event) { + _setupData (event) { if (!event.channel) { // In some situations `pc.createDataChannel()` returns `undefined` (in wrtc), // which is invalid behavior. Handle it gracefully. @@ -539,9 +539,9 @@ class Peer extends stream.Duplex { }, CHANNEL_CLOSING_TIMEOUT) } - _read() { } + _read () { } - _write(chunk, encoding, cb) { + _write (chunk, encoding, cb) { if (this.destroyed) return cb(errCode(new Error('cannot write after peer is destroyed'), 'ERR_DATA_CHANNEL')) if (this._connected) { @@ -565,7 +565,7 @@ class Peer extends stream.Duplex { // When stream finishes writing, close socket. Half open connections are not // supported. - _onFinish() { + _onFinish () { if (this.destroyed) return // Wait a bit before destroying so the socket flushes. @@ -581,7 +581,7 @@ class Peer extends stream.Duplex { } } - _startIceCompleteTimeout() { + _startIceCompleteTimeout () { if (this.destroyed) return if (this._iceCompleteTimer) return this._debug('started iceComplete timeout') @@ -595,7 +595,7 @@ class Peer extends stream.Duplex { }, this.iceCompleteTimeout) } - _createOffer() { + _createOffer () { if (this.destroyed) return this._pc.createOffer(this.offerOptions) @@ -634,7 +634,7 @@ class Peer extends stream.Duplex { }) } - _requestMissingTransceivers() { + _requestMissingTransceivers () { if (this._pc.getTransceivers) { this._pc.getTransceivers().forEach(transceiver => { if (!transceiver.mid && transceiver.sender.track && !transceiver.requested) { @@ -645,7 +645,7 @@ class Peer extends stream.Duplex { } } - _createAnswer() { + _createAnswer () { if (this.destroyed) return this._pc.createAnswer(this.answerOptions) @@ -684,7 +684,7 @@ class Peer extends stream.Duplex { }) } - _onConnectionStateChange() { + _onConnectionStateChange () { if (this.destroyed) return if (this._pc.connectionState === 'failed' && !this.iceRestartEnabled) { this.destroy(errCode(new Error('Connection failed.'), 'ERR_CONNECTION_FAILURE')) @@ -693,7 +693,7 @@ class Peer extends stream.Duplex { } } - _onIceStateChange() { + _onIceStateChange () { if (this.destroyed) return const iceConnectionState = this._pc.iceConnectionState const iceGatheringState = this._pc.iceGatheringState @@ -726,7 +726,7 @@ class Peer extends stream.Duplex { } } - getStats(cb) { + getStats (cb) { // statreports can come with a value array instead of properties const flattenValues = report => { if (Object.prototype.toString.call(report.values) === '[object Array]') { @@ -915,14 +915,14 @@ class Peer extends stream.Duplex { findCandidatePair() } - _onInterval() { + _onInterval () { if (!this._cb || !this._channel || this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) { return } this._onChannelBufferedAmountLow() } - _onSignalingStateChange() { + _onSignalingStateChange () { if (this.destroyed) return if (this._pc.signalingState === 'stable') { @@ -950,7 +950,7 @@ class Peer extends stream.Duplex { this.emit('signalingStateChange', this._pc.signalingState) } - _onIceCandidate(event) { + _onIceCandidate (event) { if (this.destroyed) return if (event.candidate && this.trickle) { this.emit('signal', { @@ -971,14 +971,14 @@ class Peer extends stream.Duplex { } } - _onChannelMessage(event) { + _onChannelMessage (event) { if (this.destroyed) return let data = event.data if (data instanceof ArrayBuffer) data = Buffer.from(data) this.push(data) } - _onChannelBufferedAmountLow() { + _onChannelBufferedAmountLow () { if (this.destroyed || !this._cb) return this._debug('ending backpressure: bufferedAmount %d', this._channel.bufferedAmount) const cb = this._cb @@ -986,20 +986,20 @@ class Peer extends stream.Duplex { cb(null) } - _onChannelOpen() { + _onChannelOpen () { if (this._connected || this.destroyed) return this._debug('on channel open') this._channelReady = true this._maybeReady() } - _onChannelClose() { + _onChannelClose () { if (this.destroyed) return this._debug('on channel close') this.destroy() } - _onTrack(event) { + _onTrack (event) { if (this.destroyed) return event.streams.forEach(eventStream => { @@ -1023,7 +1023,7 @@ class Peer extends stream.Duplex { }) } - _debug() { + _debug () { const args = [].slice.call(arguments) args[0] = '[' + this._id + '] ' + args[0] debug.apply(null, args) From be453f0737cf827356c5c1489e7421103caf91ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Oct 2021 16:57:20 +0000 Subject: [PATCH 7/7] Bump ws from 7.5.5 to 8.2.3 Bumps [ws](https://github.com/websockets/ws) from 7.5.5 to 8.2.3. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.5.5...8.2.3) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index eee1c5c4..00f61403 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "tape": "^5.0.1", "thunky": "^1.1.0", "wrtc": "^0.4.6", - "ws": "^7.3.1" + "ws": "^8.2.3" }, "keywords": [ "data",