浏览代码

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

正在加载...
取消
保存