Quellcode durchsuchen

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

tags/v0.0.2
yanas vor 8 Jahren
Ursprung
Commit
d02b756084

+ 4
- 19
modules/RTC/DataChannels.js Datei anzeigen

@@ -13,7 +13,6 @@ function DataChannels(peerConnection, emitter) {
13 13
     peerConnection.ondatachannel = this.onDataChannel.bind(this);
14 14
     this.eventEmitter = emitter;
15 15
 
16
-    this._lastNEndpoints = null;
17 16
     this._dataChannels = [];
18 17
 
19 18
     // Sample code for opening new data channel from Jitsi Meet to the bridge.
@@ -124,19 +123,17 @@ DataChannels.prototype.onDataChannel = function(event) {
124 123
                     newValue);
125 124
             } else if (colibriClass === 'LastNEndpointsChangeEvent') {
126 125
                 // The new/latest list of last-n endpoint IDs.
127
-
128
-                self._lastNEndpoints = obj.lastNEndpoints;
126
+                const lastNEndpoints = obj.lastNEndpoints;
129 127
 
130 128
                 // The list of endpoint IDs which are entering the list of
131 129
                 // last-n at this time i.e. were not in the old list of last-n
132 130
                 // endpoint IDs.
133 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 135
                 self.eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
139
-                    self._lastNEndpoints, endpointsEnteringLastN, obj);
136
+                    lastNEndpoints, endpointsEnteringLastN, obj);
140 137
             } else if (colibriClass === 'EndpointMessage') {
141 138
                 self.eventEmitter.emit(
142 139
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
@@ -307,16 +304,4 @@ DataChannels.prototype.sendSetLastNMessage = function(value) {
307 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 307
 module.exports = DataChannels;

+ 13
- 5
modules/RTC/RTC.js Datei anzeigen

@@ -133,6 +133,7 @@ export default class RTC extends Listenable {
133 133
         if (this.options.config.openSctp) {
134 134
             this.dataChannels = new DataChannels(peerconnection,
135 135
                 this.eventEmitter);
136
+
136 137
             this._dataChannelOpenListener = () => {
137 138
                 // mark that dataChannel is opened
138 139
                 this.dataChannelsOpen = true;
@@ -157,6 +158,12 @@ export default class RTC extends Listenable {
157 158
             };
158 159
             this.addListener(RTCEvents.DATA_CHANNEL_OPEN,
159 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,11 +856,12 @@ export default class RTC extends Listenable {
849 856
     /**
850 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 Datei anzeigen

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

Laden…
Abbrechen
Speichern