|
@@ -21,8 +21,9 @@ export default class BridgeChannel {
|
21
|
21
|
* instance.
|
22
|
22
|
* @param {string} [wsUrl] WebSocket URL.
|
23
|
23
|
* @param {EventEmitter} emitter the EventEmitter instance to use for event emission.
|
|
24
|
+ * @param {JitsiConference} conference the conference instance.
|
24
|
25
|
*/
|
25
|
|
- constructor(peerconnection, wsUrl, emitter) {
|
|
26
|
+ constructor(peerconnection, wsUrl, emitter, conference) {
|
26
|
27
|
if (!peerconnection && !wsUrl) {
|
27
|
28
|
throw new TypeError('At least peerconnection or wsUrl must be given');
|
28
|
29
|
} else if (peerconnection && wsUrl) {
|
|
@@ -39,6 +40,9 @@ export default class BridgeChannel {
|
39
|
40
|
// @type {RTCDataChannel|WebSocket}
|
40
|
41
|
this._channel = null;
|
41
|
42
|
|
|
43
|
+ // The conference that uses this bridge channel.
|
|
44
|
+ this._conference = conference;
|
|
45
|
+
|
42
|
46
|
// Whether the channel is connected or not. It will start as undefined
|
43
|
47
|
// for the first connection attempt. Then transition to either true or false.
|
44
|
48
|
this._connected = undefined;
|
|
@@ -377,10 +381,12 @@ export default class BridgeChannel {
|
377
|
381
|
return;
|
378
|
382
|
}
|
379
|
383
|
|
380
|
|
- // When the JVB closes the connection gracefully due to the participant being alone in
|
381
|
|
- // the meeting it uses code 1001, so treat that as a graceful close and don't say
|
382
|
|
- // anything.
|
383
|
|
- const isGracefulClose = this._closedFromClient || event.code === 1001;
|
|
384
|
+ // When the JVB closes the connection gracefully due to the participant being alone in the meeting it uses
|
|
385
|
+ // code 1001. However, the same code is also used by Cloudflare when it terminates the ws. Therefore, check
|
|
386
|
+ // for the number of remote participants in the call and abort retries only when the endpoint is the only
|
|
387
|
+ // endpoint in the call.
|
|
388
|
+ const isGracefulClose = this._closedFromClient
|
|
389
|
+ || (event.code === 1001 && this._conference.getParticipantCount() === 1);
|
384
|
390
|
|
385
|
391
|
if (!isGracefulClose) {
|
386
|
392
|
const { code, reason } = event;
|