Переглянути джерело

fix(RTC): channel not open while trying to send

Remove redundant _channelOpen flag from RTC and rely on the channel's isOpen() getter instead.
This fixes an error throw when the _channelOpen flag was not updated while the channel's been
closed by the bridge.
master
paweldomas 4 роки тому
джерело
коміт
ff1813cbb2
1 змінених файлів з 5 додано та 17 видалено
  1. 5
    17
      modules/RTC/RTC.js

+ 5
- 17
modules/RTC/RTC.js Переглянути файл

137
         // @type {BridgeChannel}
137
         // @type {BridgeChannel}
138
         this._channel = null;
138
         this._channel = null;
139
 
139
 
140
-        // A flag whether we had received that the channel had opened we can
141
-        // get this flag out of sync if for some reason channel got closed
142
-        // from server, a desired behaviour so we can see errors when this
143
-        // happen.
144
-        // @private
145
-        // @type {boolean}
146
-        this._channelOpen = false;
147
-
148
         /**
140
         /**
149
          * The value specified to the last invocation of setLastN before the
141
          * The value specified to the last invocation of setLastN before the
150
          * channel completed opening. If non-null, the value will be sent
142
          * channel completed opening. If non-null, the value will be sent
292
             peerconnection, wsUrl, this.eventEmitter, this._senderVideoConstraintsChanged.bind(this));
284
             peerconnection, wsUrl, this.eventEmitter, this._senderVideoConstraintsChanged.bind(this));
293
 
285
 
294
         this._channelOpenListener = () => {
286
         this._channelOpenListener = () => {
295
-            // Mark that channel as opened.
296
-            this._channelOpen = true;
297
-
298
             // When the channel becomes available, tell the bridge about
287
             // When the channel becomes available, tell the bridge about
299
             // video selections so that it can do adaptive simulcast,
288
             // video selections so that it can do adaptive simulcast,
300
             // we want the notification to trigger even if userJid
289
             // we want the notification to trigger even if userJid
403
             }
392
             }
404
 
393
 
405
             this._channel = null;
394
             this._channel = null;
406
-            this._channelOpen = false;
407
         }
395
         }
408
     }
396
     }
409
 
397
 
419
     setReceiverVideoConstraint(maxFrameHeight) {
407
     setReceiverVideoConstraint(maxFrameHeight) {
420
         this._maxFrameHeight = maxFrameHeight;
408
         this._maxFrameHeight = maxFrameHeight;
421
 
409
 
422
-        if (this._channel && this._channelOpen) {
410
+        if (this._channel && this._channel.isOpen()) {
423
             this._channel.sendReceiverVideoConstraintMessage(maxFrameHeight);
411
             this._channel.sendReceiverVideoConstraintMessage(maxFrameHeight);
424
         }
412
         }
425
     }
413
     }
438
     selectEndpoints(ids) {
426
     selectEndpoints(ids) {
439
         this._selectedEndpoints = ids;
427
         this._selectedEndpoints = ids;
440
 
428
 
441
-        if (this._channel && this._channelOpen) {
429
+        if (this._channel && this._channel.isOpen()) {
442
             this._channel.sendSelectedEndpointsMessage(ids);
430
             this._channel.sendSelectedEndpointsMessage(ids);
443
         }
431
         }
444
     }
432
     }
454
     pinEndpoint(id) {
442
     pinEndpoint(id) {
455
         // Cache the value if channel is missing, till we open it.
443
         // Cache the value if channel is missing, till we open it.
456
         this._pinnedEndpoint = id;
444
         this._pinnedEndpoint = id;
457
-        if (this._channel && this._channelOpen) {
445
+        if (this._channel && this._channel.isOpen()) {
458
             this._channel.sendPinnedEndpointMessage(id);
446
             this._channel.sendPinnedEndpointMessage(id);
459
         }
447
         }
460
     }
448
     }
894
     closeBridgeChannel() {
882
     closeBridgeChannel() {
895
         if (this._channel) {
883
         if (this._channel) {
896
             this._channel.close();
884
             this._channel.close();
897
-            this._channelOpen = false;
885
+            this._channel = null;
898
 
886
 
899
             this.removeListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
887
             this.removeListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
900
                 this._lastNChangeListener);
888
                 this._lastNChangeListener);
953
     setLastN(value) {
941
     setLastN(value) {
954
         if (this._lastN !== value) {
942
         if (this._lastN !== value) {
955
             this._lastN = value;
943
             this._lastN = value;
956
-            if (this._channel && this._channelOpen) {
944
+            if (this._channel && this._channel.isOpen()) {
957
                 this._channel.sendSetLastNMessage(value);
945
                 this._channel.sendSetLastNMessage(value);
958
             }
946
             }
959
             this.eventEmitter.emit(RTCEvents.LASTN_VALUE_CHANGED, value);
947
             this.eventEmitter.emit(RTCEvents.LASTN_VALUE_CHANGED, value);

Завантаження…
Відмінити
Зберегти