Skip to content

Commit

Permalink
feat(plugin-meetings): set up the listeners before triggering ice gat…
Browse files Browse the repository at this point in the history
…hering (#4025)
  • Loading branch information
Coread authored Dec 11, 2024
1 parent 056f75f commit 9902ae8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,14 @@ export class ClusterReachability extends EventsScope {

this.startTimestamp = performance.now();

// Set up the state change listeners before triggering the ICE gathering
const gatherIceCandidatePromise = this.gatherIceCandidates();

// not awaiting the next call on purpose, because we're not sending the offer anywhere and there won't be any answer
// we just need to make this call to trigger the ICE gathering process
this.pc.setLocalDescription(offer);

await this.gatherIceCandidates();
await gatherIceCandidatePromise;
} catch (error) {
LoggerProxy.logger.warn(`Reachability:ClusterReachability#start --> Error: `, error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('ClusterReachability', () => {
let previousRTCPeerConnection;
let clusterReachability;
let fakePeerConnection;
let gatherIceCandidatesSpy;

const emittedEvents: Record<Events, (ResultEventData | ClientMediaIpsUpdatedEventData)[]> = {
[Events.resultReady]: [],
Expand Down Expand Up @@ -44,6 +45,8 @@ describe('ClusterReachability', () => {
xtls: ['stun:xtls1.webex.com', 'stun:xtls2.webex.com:443'],
});

gatherIceCandidatesSpy = sinon.spy(clusterReachability, 'gatherIceCandidates');

resetEmittedEvents();

clusterReachability.on(Events.resultReady, (data: ResultEventData) => {
Expand Down Expand Up @@ -151,6 +154,10 @@ describe('ClusterReachability', () => {
assert.calledOnceWithExactly(fakePeerConnection.createOffer, {offerToReceiveAudio: true});
assert.calledOnce(fakePeerConnection.setLocalDescription);

// Make sure that gatherIceCandidates is called before setLocalDescription
// as setLocalDescription triggers the ICE gathering process
assert.isTrue(gatherIceCandidatesSpy.calledBefore(fakePeerConnection.setLocalDescription));

clusterReachability.abort();
await promise;

Expand Down

0 comments on commit 9902ae8

Please sign in to comment.