|
@@ -3,6 +3,7 @@ import { getLogger } from 'jitsi-meet-logger';
|
3
|
3
|
import { createE2eRttEvent } from '../../service/statistics/AnalyticsEvents';
|
4
|
4
|
import * as E2ePingEvents
|
5
|
5
|
from '../../service/e2eping/E2ePingEvents';
|
|
6
|
+import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
|
6
|
7
|
import Statistics from '../statistics/statistics';
|
7
|
8
|
|
8
|
9
|
const logger = getLogger(__filename);
|
|
@@ -175,12 +176,13 @@ class ParticipantWrapper {
|
175
|
176
|
*/
|
176
|
177
|
export default class E2ePing {
|
177
|
178
|
/**
|
178
|
|
- * @param {EventEmitter} eventEmitter - The object to use to emit events.
|
|
179
|
+ * @param {JitsiConference} conference - The conference.
|
179
|
180
|
* @param {Function} sendMessage - The function to use to send a message.
|
180
|
181
|
* @param {Object} options
|
181
|
182
|
*/
|
182
|
|
- constructor(eventEmitter, options, sendMessage) {
|
183
|
|
- this.eventEmitter = eventEmitter;
|
|
183
|
+ constructor(conference, options, sendMessage) {
|
|
184
|
+ this.conference = conference;
|
|
185
|
+ this.eventEmitter = conference.eventEmitter;
|
184
|
186
|
this.sendMessage = sendMessage;
|
185
|
187
|
|
186
|
188
|
// The interval at which pings will be sent (<= 0 disables sending).
|
|
@@ -213,6 +215,26 @@ export default class E2ePing {
|
213
|
215
|
`Initializing e2e ping; pingInterval=${
|
214
|
216
|
this.pingIntervalMs}, analyticsInterval=${
|
215
|
217
|
this.analyticsIntervalMs}.`);
|
|
218
|
+
|
|
219
|
+ this.participantJoined = this.participantJoined.bind(this);
|
|
220
|
+ conference.on(
|
|
221
|
+ JitsiConferenceEvents.USER_JOINED,
|
|
222
|
+ this.participantJoined);
|
|
223
|
+
|
|
224
|
+ this.participantLeft = this.participantLeft.bind(this);
|
|
225
|
+ conference.on(
|
|
226
|
+ JitsiConferenceEvents.USER_LEFT,
|
|
227
|
+ this.participantLeft);
|
|
228
|
+
|
|
229
|
+ this.messageReceived = this.messageReceived.bind(this);
|
|
230
|
+ conference.on(
|
|
231
|
+ JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
|
232
|
+ this.messageReceived);
|
|
233
|
+
|
|
234
|
+ this.dataChannelOpened = this.dataChannelOpened.bind(this);
|
|
235
|
+ conference.on(
|
|
236
|
+ JitsiConferenceEvents.DATA_CHANNEL_OPENED,
|
|
237
|
+ this.dataChannelOpened);
|
216
|
238
|
}
|
217
|
239
|
|
218
|
240
|
/**
|
|
@@ -258,11 +280,10 @@ export default class E2ePing {
|
258
|
280
|
* Handles a participant joining the conference. Starts to send ping
|
259
|
281
|
* requests to the participant.
|
260
|
282
|
*
|
|
283
|
+ * @param {String} id - The ID of the participant.
|
261
|
284
|
* @param {JitsiParticipant} participant - The participant that joined.
|
262
|
285
|
*/
|
263
|
|
- participantJoined(participant) {
|
264
|
|
- const id = participant.getId();
|
265
|
|
-
|
|
286
|
+ participantJoined(id, participant) {
|
266
|
287
|
if (this.pingIntervalMs <= 0) {
|
267
|
288
|
return;
|
268
|
289
|
}
|
|
@@ -280,11 +301,9 @@ export default class E2ePing {
|
280
|
301
|
/**
|
281
|
302
|
* Handles a participant leaving the conference. Stops sending requests.
|
282
|
303
|
*
|
283
|
|
- * @param {JitsiParticipant} participant - The participant that left.
|
|
304
|
+ * @param {String} id - The ID of the participant.
|
284
|
305
|
*/
|
285
|
|
- participantLeft(participant) {
|
286
|
|
- const id = participant.getId();
|
287
|
|
-
|
|
306
|
+ participantLeft(id) {
|
288
|
307
|
if (this.pingIntervalMs <= 0) {
|
289
|
308
|
return;
|
290
|
309
|
}
|
|
@@ -337,6 +356,19 @@ export default class E2ePing {
|
337
|
356
|
stop() {
|
338
|
357
|
logger.info('Stopping e2eping');
|
339
|
358
|
|
|
359
|
+ this.conference.off(
|
|
360
|
+ JitsiConferenceEvents.USER_JOINED,
|
|
361
|
+ this.participantJoined);
|
|
362
|
+ this.conference.off(
|
|
363
|
+ JitsiConferenceEvents.USER_LEFT,
|
|
364
|
+ this.participantLeft);
|
|
365
|
+ this.conference.off(
|
|
366
|
+ JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
|
|
367
|
+ this.messageReceived);
|
|
368
|
+ this.conference.off(
|
|
369
|
+ JitsiConferenceEvents.DATA_CHANNEL_OPENED,
|
|
370
|
+ this.dataChannelOpened);
|
|
371
|
+
|
340
|
372
|
for (const id in this.participants) {
|
341
|
373
|
if (this.participants.hasOwnProperty(id)) {
|
342
|
374
|
this.participants[id].clearIntervals();
|