Przeglądaj źródła

Changes lastN event params to be leaving and entering endpoint IDs.

dev1
damencho 8 lat temu
rodzic
commit
5158c4f352

+ 0
- 6
JitsiConferenceEventManager.js Wyświetl plik

@@ -461,9 +461,6 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
461 461
     const conference = this.conference;
462 462
     const rtc = conference.rtc;
463 463
 
464
-    this.rtcForwarder
465
-        = new EventEmitterForwarder(rtc, this.conference.eventEmitter);
466
-
467 464
     rtc.addListener(
468 465
         RTCEvents.REMOTE_TRACK_ADDED,
469 466
         conference.onRemoteTrackAdded.bind(conference));
@@ -494,9 +491,6 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
494 491
             { value: now });
495 492
     });
496 493
 
497
-    this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
498
-        JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
499
-
500 494
     rtc.addListener(
501 495
         RTCEvents.AVAILABLE_DEVICES_CHANGED,
502 496
         devices => conference.room.updateDeviceAvailability(devices));

+ 5
- 0
JitsiConferenceEvents.js Wyświetl plik

@@ -90,6 +90,11 @@ export const KICKED = 'conferenece.kicked';
90 90
 
91 91
 /**
92 92
  * The Last N set is changed.
93
+ *
94
+ * @param {Array<string>|null} leavingEndpointIds the ids of all the endpoints
95
+ * which are leaving Last N
96
+ * @param {Array<string>|null} enteringEndpointIds the ids of all the endpoints
97
+ * which are entering Last N
93 98
  */
94 99
 export const LAST_N_ENDPOINTS_CHANGED = 'conference.lastNEndpointsChanged';
95 100
 

+ 1
- 2
doc/API.md Wyświetl plik

@@ -109,8 +109,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
109 109
         - MESSAGE_RECEIVED - new text message received. (parameters - id(string), text(string), ts(number))
110 110
         - DISPLAY_NAME_CHANGED - user has changed his display name. (parameters - id(string), displayName(string))
111 111
         - SUBJECT_CHANGED - notifies that subject of the conference has changed (parameters - subject(string))
112
-        - LAST_N_ENDPOINTS_CHANGED - last n set was changed (parameters - array of ids of users)
113
-        - IN_LAST_N_CHANGED - passes boolean property that shows whether the local user is included in last n set of any other user or not. (parameters - boolean)
112
+        - LAST_N_ENDPOINTS_CHANGED - last n set was changed (parameters - leavingEndpointIds(array) ids of users leaving lastN, enteringEndpointIds(array) ids of users entering lastN)
114 113
         - CONFERENCE_JOINED - notifies the local user that he joined the conference successfully. (no parameters)
115 114
         - CONFERENCE_LEFT - notifies the local user that he left the conference successfully. (no parameters)
116 115
         - DTMF_SUPPORT_CHANGED - notifies if at least one user supports DTMF. (parameters - supports(boolean))

+ 2
- 7
modules/RTC/DataChannels.js Wyświetl plik

@@ -99,15 +99,10 @@ DataChannels.prototype.onDataChannel = function(event) {
99 99
                 // The new/latest list of last-n endpoint IDs.
100 100
                 const lastNEndpoints = obj.lastNEndpoints;
101 101
 
102
-                // The list of endpoint IDs which are entering the list of
103
-                // last-n at this time i.e. were not in the old list of last-n
104
-                // endpoint IDs.
105
-                const endpointsEnteringLastN = obj.endpointsEnteringLastN;
106
-
107 102
                 logger.info('Data channel new last-n event: ',
108
-                    lastNEndpoints, endpointsEnteringLastN, obj);
103
+                    lastNEndpoints, obj);
109 104
                 self.eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
110
-                    lastNEndpoints, endpointsEnteringLastN, obj);
105
+                    lastNEndpoints, obj);
111 106
             } else if (colibriClass === 'EndpointMessage') {
112 107
                 self.eventEmitter.emit(
113 108
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,

+ 32
- 9
modules/RTC/RTC.js Wyświetl plik

@@ -2,6 +2,7 @@
2 2
 import DataChannels from './DataChannels';
3 3
 import { getLogger } from 'jitsi-meet-logger';
4 4
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
5
+import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
5 6
 import JitsiLocalTrack from './JitsiLocalTrack.js';
6 7
 import JitsiTrackError from '../../JitsiTrackError';
7 8
 import * as JitsiTrackErrors from '../../JitsiTrackErrors';
@@ -90,7 +91,7 @@ export default class RTC extends Listenable {
90 91
         this._lastNEndpoints = null;
91 92
 
92 93
         // The last N change listener.
93
-        this._lastNChangeListener = null;
94
+        this._lastNChangeListener = this._onLastNChanged.bind(this);
94 95
 
95 96
         // Switch audio output device on all remote audio tracks. Local audio
96 97
         // tracks handle this event by themselves.
@@ -169,15 +170,39 @@ export default class RTC extends Listenable {
169 170
                 this._dataChannelOpenListener);
170 171
 
171 172
             // Add Last N change listener.
172
-            this._lastNChangeListener = lastNEndpoints => {
173
-                this._lastNEndpoints = lastNEndpoints;
174
-            };
175
-
176 173
             this.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
177 174
                 this._lastNChangeListener);
178 175
         }
179 176
     }
180 177
 
178
+    /**
179
+     * Receives events when Last N had changed.
180
+     * @param {array} lastNEndpoints the new Last N endpoints.
181
+     * @private
182
+     */
183
+    _onLastNChanged(lastNEndpoints) {
184
+        const oldLastNEndpoints = this._lastNEndpoints;
185
+        let leavingLastNEndpoints = [];
186
+        let enteringLastNEndpoints = [];
187
+
188
+        this._lastNEndpoints = lastNEndpoints;
189
+
190
+        if (oldLastNEndpoints) {
191
+            leavingLastNEndpoints = oldLastNEndpoints.filter(
192
+                id => !this.isInLastN(id));
193
+
194
+            if (lastNEndpoints) {
195
+                enteringLastNEndpoints = lastNEndpoints.filter(
196
+                    id => oldLastNEndpoints.indexOf(id) === -1);
197
+            }
198
+        }
199
+
200
+        this.conference.eventEmitter.emit(
201
+            JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
202
+            leavingLastNEndpoints,
203
+            enteringLastNEndpoints);
204
+    }
205
+
181 206
     /**
182 207
      * Should be called when current media session ends and after the
183 208
      * PeerConnection has been closed using PeerConnection.close() method.
@@ -600,10 +625,8 @@ export default class RTC extends Listenable {
600 625
             this.dataChannels.closeAllChannels();
601 626
             this.dataChannelsOpen = false;
602 627
 
603
-            if (this._lastNChangeListener) {
604
-                this.removeListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
605
-                    this._lastNChangeListener);
606
-            }
628
+            this.removeListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
629
+                this._lastNChangeListener);
607 630
         }
608 631
     }
609 632
 

Ładowanie…
Anuluj
Zapisz