fix(screenshare): make viewers reconnect immediately mid-call

If a viewer session failed mid-call, it was being scheduled for a reconnect via
the min-max connection timers (30s-60s), which is terrible UX.

This commit makes screen sharing viewers try to reconnect immediately when
appropriate.
This commit is contained in:
prlanzarin 2022-05-08 21:21:22 +00:00
parent d45aecdbcc
commit 53570deb86

View File

@ -144,11 +144,13 @@ export default class KurentoScreenshareBridge {
return this.connectionAttempts > BridgeService.MAX_CONN_ATTEMPTS;
}
scheduleReconnect () {
scheduleReconnect(immediate = false) {
if (this.reconnectionTimeout == null) {
const nextRestartInterval = immediate ? 0 : this.restartIntervalMs;
this.reconnectionTimeout = setTimeout(
this.handleConnectionTimeoutExpiry.bind(this),
this.restartIntervalMs
nextRestartInterval,
);
}
}
@ -216,7 +218,9 @@ export default class KurentoScreenshareBridge {
// during call; schedule a reconnect
// If the session has not yet started, a reconnect should already be scheduled
if (this._shouldReconnect()) {
this.scheduleReconnect();
// this.broker.started => whether the reconnect should happen immediately.
// If this session had alredy been established, it should.
this.scheduleReconnect(this.broker.started);
}
return error;