Просмотр исходного кода

Merge pull request #254 from jitsi/dc-cached-values

Sends non cached values only if datachannel is open.
dev1
Paweł Domas 9 лет назад
Родитель
Сommit
505fc86fa2
1 измененных файлов: 12 добавлений и 2 удалений
  1. 12
    2
      modules/RTC/RTC.js

+ 12
- 2
modules/RTC/RTC.js Просмотреть файл

@@ -47,6 +47,11 @@ function RTC(conference, options) {
47 47
     this.eventEmitter = new EventEmitter();
48 48
     var self = this;
49 49
     this.options = options || {};
50
+    // A flag whether we had received that the data channel had opened
51
+    // we can get this flag out of sync if for some reason data channel got
52
+    // closed from server, a desired behaviour so we can see errors when this
53
+    // happen
54
+    this.dataChannelsOpen = false;
50 55
 
51 56
     // Switch audio output device on all remote audio tracks. Local audio tracks
52 57
     // handle this event by themselves.
@@ -93,6 +98,8 @@ RTC.prototype.onIncommingCall = function(event) {
93 98
         this.dataChannels = new DataChannels(event.peerconnection,
94 99
             this.eventEmitter);
95 100
         this._dataChannelOpenListener = () => {
101
+            // mark that dataChannel is opened
102
+            this.dataChannelsOpen = true;
96 103
             // when the data channel becomes available, tell the bridge
97 104
             // about video selections so that it can do adaptive simulcast,
98 105
             // we want the notification to trigger even if userJid
@@ -127,6 +134,7 @@ RTC.prototype.onCallEnded = function() {
127 134
         // The reference is cleared to disable any logic related to the data
128 135
         // channels.
129 136
         this.dataChannels = null;
137
+        this.dataChannelsOpen = false;
130 138
     }
131 139
 };
132 140
 
@@ -142,7 +150,7 @@ RTC.prototype.onCallEnded = function() {
142 150
 RTC.prototype.selectEndpoint = function (id) {
143 151
     // cache the value if channel is missing, till we open it
144 152
     this.selectedEndpoint = id;
145
-    if(this.dataChannels)
153
+    if(this.dataChannels && this.dataChannelsOpen)
146 154
         this.dataChannels.sendSelectedEndpointMessage(id);
147 155
 };
148 156
 
@@ -459,8 +467,10 @@ RTC.isDesktopSharingEnabled = function () {
459 467
  * Closes all currently opened data channels.
460 468
  */
461 469
 RTC.prototype.closeAllDataChannels = function () {
462
-    if(this.dataChannels)
470
+    if(this.dataChannels) {
463 471
         this.dataChannels.closeAllChannels();
472
+        this.dataChannelsOpen = false;
473
+    }
464 474
 };
465 475
 
466 476
 RTC.prototype.dispose = function() {

Загрузка…
Отмена
Сохранить