This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch main in repository pluggable-transports/snowflake-webext.
commit 71817a00c405604c2d81051ee1bc95aa1f118fcc Author: WofWca wofwca@protonmail.com AuthorDate: Fri Nov 4 13:55:12 2022 +0400
refactor: use `icegatheringstatechange` instead of `onicecandidate` --- proxypair.js | 7 +++---- spec/proxypair.spec.js | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/proxypair.js b/proxypair.js index f0adba6..4b7c115 100644 --- a/proxypair.js +++ b/proxypair.js @@ -69,12 +69,11 @@ class ProxyPair { const onceSendAnswer = () => { snowflake.broker.sendAnswer(this.id, this.pc.localDescription);
- this.pc.onicecandidate = null; + this.pc.onicegatheringstatechange = null; clearTimeout(this.answerTimeoutId); }; - this.pc.onicecandidate = (evt) => { - // Browser sends a null candidate once the ICE gathering completes. - if (null === evt.candidate && this.pc.connectionState !== 'closed') { + this.pc.onicegatheringstatechange = () => { + if (this.pc.iceGatheringState === 'complete' && this.pc.connectionState !== 'closed') { dbg('Finished gathering ICE candidates.'); onceSendAnswer(); } diff --git a/spec/proxypair.spec.js b/spec/proxypair.spec.js index 8e0b330..6cf71f2 100644 --- a/spec/proxypair.spec.js +++ b/spec/proxypair.spec.js @@ -84,9 +84,8 @@ describe('ProxyPair', function() { type: 'offer', sdp: 'foo' }); - pp.pc.onicecandidate({ - candidate: null - }); + pp.pc.iceGatheringState = 'complete'; + pp.pc.onicegatheringstatechange(); expect(snowflake.broker.sendAnswer).toHaveBeenCalled(); });