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

fix(DataChannels):Moves last n list handling to RTC

tags/v0.0.2
yanas 8 лет назад
Родитель
Сommit
d02b756084
3 измененных файлов: 18 добавлений и 25 удалений
  1. 4
    19
      modules/RTC/DataChannels.js
  2. 13
    5
      modules/RTC/RTC.js
  3. 1
    1
      modules/connectivity/ParticipantConnectionStatus.js

+ 4
- 19
modules/RTC/DataChannels.js Просмотреть файл

13
     peerConnection.ondatachannel = this.onDataChannel.bind(this);
13
     peerConnection.ondatachannel = this.onDataChannel.bind(this);
14
     this.eventEmitter = emitter;
14
     this.eventEmitter = emitter;
15
 
15
 
16
-    this._lastNEndpoints = null;
17
     this._dataChannels = [];
16
     this._dataChannels = [];
18
 
17
 
19
     // Sample code for opening new data channel from Jitsi Meet to the bridge.
18
     // Sample code for opening new data channel from Jitsi Meet to the bridge.
124
                     newValue);
123
                     newValue);
125
             } else if (colibriClass === 'LastNEndpointsChangeEvent') {
124
             } else if (colibriClass === 'LastNEndpointsChangeEvent') {
126
                 // The new/latest list of last-n endpoint IDs.
125
                 // The new/latest list of last-n endpoint IDs.
127
-
128
-                self._lastNEndpoints = obj.lastNEndpoints;
126
+                const lastNEndpoints = obj.lastNEndpoints;
129
 
127
 
130
                 // The list of endpoint IDs which are entering the list of
128
                 // The list of endpoint IDs which are entering the list of
131
                 // last-n at this time i.e. were not in the old list of last-n
129
                 // last-n at this time i.e. were not in the old list of last-n
132
                 // endpoint IDs.
130
                 // endpoint IDs.
133
                 const endpointsEnteringLastN = obj.endpointsEnteringLastN;
131
                 const endpointsEnteringLastN = obj.endpointsEnteringLastN;
134
 
132
 
135
-                logger.info(
136
-                    'Data channel new last-n event: ',
137
-                        self._lastNEndpoints, endpointsEnteringLastN, obj);
133
+                logger.info('Data channel new last-n event: ',
134
+                    lastNEndpoints, endpointsEnteringLastN, obj);
138
                 self.eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
135
                 self.eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
139
-                    self._lastNEndpoints, endpointsEnteringLastN, obj);
136
+                    lastNEndpoints, endpointsEnteringLastN, obj);
140
             } else if (colibriClass === 'EndpointMessage') {
137
             } else if (colibriClass === 'EndpointMessage') {
141
                 self.eventEmitter.emit(
138
                 self.eventEmitter.emit(
142
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
139
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
307
     logger.log(`Channel lastN set to: ${value}`);
304
     logger.log(`Channel lastN set to: ${value}`);
308
 };
305
 };
309
 
306
 
310
-/**
311
- * Indicates if the endpoint id is currently included in the last N.
312
- *
313
- * @param id the endpoint id that we check for last N
314
- * @returns {boolean} {true} if the endpoint id is in the last N or if we
315
- * haven't initialised the last N array yet and {false} otherwise
316
- */
317
-DataChannels.prototype.isInLastN = function (id) {
318
-    return !this._lastNEndpoints // lastNEndpoints not initialised yet
319
-        || this._lastNEndpoints.indexOf(id) > -1;
320
-};
321
-
322
 module.exports = DataChannels;
307
 module.exports = DataChannels;

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

133
         if (this.options.config.openSctp) {
133
         if (this.options.config.openSctp) {
134
             this.dataChannels = new DataChannels(peerconnection,
134
             this.dataChannels = new DataChannels(peerconnection,
135
                 this.eventEmitter);
135
                 this.eventEmitter);
136
+
136
             this._dataChannelOpenListener = () => {
137
             this._dataChannelOpenListener = () => {
137
                 // mark that dataChannel is opened
138
                 // mark that dataChannel is opened
138
                 this.dataChannelsOpen = true;
139
                 this.dataChannelsOpen = true;
157
             };
158
             };
158
             this.addListener(RTCEvents.DATA_CHANNEL_OPEN,
159
             this.addListener(RTCEvents.DATA_CHANNEL_OPEN,
159
                 this._dataChannelOpenListener);
160
                 this._dataChannelOpenListener);
161
+
162
+            this.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
163
+                lastNEndpoints => {
164
+                    this._lastNEndpoints = lastNEndpoints;
165
+                }
166
+            );
160
         }
167
         }
161
     }
168
     }
162
 
169
 
849
     /**
856
     /**
850
      * Indicates if the endpoint id is currently included in the last N.
857
      * Indicates if the endpoint id is currently included in the last N.
851
      *
858
      *
852
-     * @param id the endpoint id that we check for last N
853
-     * @returns {boolean} {true} if the endpoint id is in the last N or if we
854
-     * don't have data channel support, otherwise we return {false}
859
+     * @param {string} id the endpoint id that we check for last N
860
+     * @returns {boolean} true if the endpoint id is in the last N or if we
861
+     * don't have data channel support, otherwise we return false
855
      */
862
      */
856
-    isInLastN (id) {
857
-        return (this.dataChannels) ? this.dataChannels.isInLastN(id) : true;
863
+    isInLastN(id) {
864
+        return !this._lastNEndpoints // lastNEndpoints not initialised yet
865
+            || this._lastNEndpoints.indexOf(id) > -1;
858
     }
866
     }
859
 }
867
 }

+ 1
- 1
modules/connectivity/ParticipantConnectionStatus.js Просмотреть файл

363
             `Figure out conn status, is video muted: ${isVideoMuted
363
             `Figure out conn status, is video muted: ${isVideoMuted
364
                  } is active(jvb): ${isConnActiveByJvb
364
                  } is active(jvb): ${isConnActiveByJvb
365
                  } video track frozen: ${isVideoTrackFrozen
365
                  } video track frozen: ${isVideoTrackFrozen
366
-                 } is in last N: ${isInLastN}
366
+                 } is in last N: ${isInLastN
367
                  } => ${isConnectionActive}`);
367
                  } => ${isConnectionActive}`);
368
 
368
 
369
         this._changeConnectionStatus(participant, isConnectionActive);
369
         this._changeConnectionStatus(participant, isConnectionActive);

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