Skip to content

Commit

Permalink
feat: fast-reconnects for network switching
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlaz committed Dec 11, 2023
1 parent 53f4c72 commit e7318d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/client/src/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,11 @@ export class Call {
currentCallingState === CallingState.RECONNECTING_FAILED;
if (!shouldReconnect) return;
this.logger('info', '[Rejoin]: Going online...');
let isFirstReconnectAttempt = true;
do {
try {
await reconnect();
sfuClient.isFastReconnecting = isFirstReconnectAttempt;
await reconnect(isFirstReconnectAttempt ? 'fast' : 'full');
return; // break the loop if rejoin is successful
} catch (err) {
this.logger(
Expand All @@ -912,6 +914,7 @@ export class Call {
}
// wait for a bit before trying to reconnect again
await sleep(retryInterval(this.reconnectAttempts));
isFirstReconnectAttempt = false;
} while (this.reconnectAttempts < this.maxReconnectAttempts);

// if we're here, it means that we've exhausted all the reconnect attempts
Expand Down

0 comments on commit e7318d7

Please sign in to comment.