Przeglądaj źródła

fix(BridgeChannel) skip close notification if the code is 1001

That's a graceful close by the bridge.

Reorganized the logic a bit to make it more clear.
tags/v0.0.2
Saúl Ibarra Corretgé 2 lat temu
rodzic
commit
475610584e
1 zmienionych plików z 12 dodań i 9 usunięć
  1. 12
    9
      modules/RTC/BridgeChannel.js

+ 12
- 9
modules/RTC/BridgeChannel.js Wyświetl plik

@@ -430,21 +430,22 @@ export default class BridgeChannel {
430 430
                 return;
431 431
             }
432 432
 
433
-            if (this._mode === 'websocket') {
434
-                if (!this._closedFromClient) {
435
-                    this._retryWebSocketConnection(event);
436
-                }
437
-            }
433
+            // When the JVB closes the connection gracefully due to the participant being alone in
434
+            // the meeting it uses code 1001, so treat that as a graceful close and don't say
435
+            // anything.
436
+            const isGracefulClose = this._closedFromClient || event.code === 1001;
438 437
 
439
-            if (!this._closedFromClient) {
438
+            if (!isGracefulClose) {
440 439
                 const { code, reason } = event;
441 440
 
442 441
                 logger.error(`Channel closed: ${code} ${reason}`);
443 442
 
444
-                // We only want to send this event the first time the failure happens.
445
-                if (typeof this._connected === 'undefined' || this._connected) {
446
-                    this._connected = false;
443
+                if (this._mode === 'websocket') {
444
+                    this._retryWebSocketConnection(event);
445
+                }
447 446
 
447
+                // We only want to send this event the first time the failure happens.
448
+                if (this._connected !== false) {
448 449
                     emitter.emit(RTCEvents.DATA_CHANNEL_CLOSED, {
449 450
                         code,
450 451
                         reason
@@ -452,6 +453,8 @@ export default class BridgeChannel {
452 453
                 }
453 454
             }
454 455
 
456
+            this._connected = false;
457
+
455 458
             // Remove the channel.
456 459
             this._channel = null;
457 460
         };

Ładowanie…
Anuluj
Zapisz