Преглед на файлове

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 години
родител
ревизия
475610584e
променени са 1 файла, в които са добавени 12 реда и са изтрити 9 реда
  1. 12
    9
      modules/RTC/BridgeChannel.js

+ 12
- 9
modules/RTC/BridgeChannel.js Целия файл

430
                 return;
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
                 const { code, reason } = event;
439
                 const { code, reason } = event;
441
 
440
 
442
                 logger.error(`Channel closed: ${code} ${reason}`);
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
                     emitter.emit(RTCEvents.DATA_CHANNEL_CLOSED, {
449
                     emitter.emit(RTCEvents.DATA_CHANNEL_CLOSED, {
449
                         code,
450
                         code,
450
                         reason
451
                         reason
452
                 }
453
                 }
453
             }
454
             }
454
 
455
 
456
+            this._connected = false;
457
+
455
             // Remove the channel.
458
             // Remove the channel.
456
             this._channel = null;
459
             this._channel = null;
457
         };
460
         };

Loading…
Отказ
Запис