Explorar el Código

feat(JitsiConference): emit ACTION_JINGLE_SI_TIMEOUT

Emit ACTION_JINGLE_SI_TIMEOUT analytics event if it takes too long for
Jicofo to send session-initiate (it usually arrives within 1 second).
dev1
paweldomas hace 7 años
padre
commit
3e0ed6c7b1
Se han modificado 2 ficheros con 55 adiciones y 1 borrados
  1. 47
    1
      JitsiConference.js
  2. 8
    0
      service/statistics/AnalyticsEvents.js

+ 47
- 1
JitsiConference.js Ver fichero

@@ -4,6 +4,7 @@ import { Strophe } from 'strophe.js';
4 4
 import {
5 5
     ACTION_JINGLE_RESTART,
6 6
     ACTION_JINGLE_SI_RECEIVED,
7
+    ACTION_JINGLE_SI_TIMEOUT,
7 8
     ACTION_JINGLE_TERMINATE,
8 9
     ACTION_P2P_ESTABLISHED,
9 10
     ACTION_P2P_FAILED,
@@ -50,6 +51,13 @@ import SpeakerStatsCollector from './modules/statistics/SpeakerStatsCollector';
50 51
 
51 52
 const logger = getLogger(__filename);
52 53
 
54
+/**
55
+ * How long since Jicofo is supposed to send a session-initiate, before
56
+ * {@link ACTION_JINGLE_SI_TIMEOUT} analytics event is sent (in ms).
57
+ * @type {number}
58
+ */
59
+const JINGLE_SI_TIMEOUT = 5000;
60
+
53 61
 /**
54 62
  * Creates a JitsiConference object with the given name and properties.
55 63
  * Note: this constructor is not a part of the public API (objects should be
@@ -361,7 +369,7 @@ JitsiConference.prototype._init = function(options = {}) {
361 369
  */
362 370
 JitsiConference.prototype.join = function(password) {
363 371
     if (this.room) {
364
-        this.room.join(password);
372
+        this.room.join(password).then(() => this._maybeSetSITimeout());
365 373
     }
366 374
 };
367 375
 
@@ -1216,6 +1224,41 @@ JitsiConference.prototype.kickParticipant = function(id) {
1216 1224
     this.room.kick(participant.getJid());
1217 1225
 };
1218 1226
 
1227
+/**
1228
+ * Maybe clears the timeout which emits {@link ACTION_JINGLE_SI_TIMEOUT}
1229
+ * analytics event.
1230
+ * @private
1231
+ */
1232
+JitsiConference.prototype._maybeClearSITimeout = function() {
1233
+    if (this._sessionInitiateTimeout
1234
+            && (this.jvbJingleSession || this.getParticipantCount() < 2)) {
1235
+        window.clearTimeout(this._sessionInitiateTimeout);
1236
+        this._sessionInitiateTimeout = null;
1237
+    }
1238
+};
1239
+
1240
+/**
1241
+ * Sets a timeout which will emit {@link ACTION_JINGLE_SI_TIMEOUT} analytics
1242
+ * event.
1243
+ * @private
1244
+ */
1245
+JitsiConference.prototype._maybeSetSITimeout = function() {
1246
+    // Jicofo is supposed to invite if there are at least 2 participants
1247
+    if (!this.jvbJingleSession
1248
+            && this.getParticipantCount() >= 2
1249
+            && !this._sessionInitiateTimeout) {
1250
+        this._sessionInitiateTimeout = window.setTimeout(() => {
1251
+            this._sessionInitiateTimeout = null;
1252
+            Statistics.sendAnalytics(createJingleEvent(
1253
+                ACTION_JINGLE_SI_TIMEOUT,
1254
+                {
1255
+                    p2p: false,
1256
+                    value: JINGLE_SI_TIMEOUT
1257
+                }));
1258
+        }, JINGLE_SI_TIMEOUT);
1259
+    }
1260
+};
1261
+
1219 1262
 /**
1220 1263
  * Mutes a participant.
1221 1264
  * @param {string} id The id of the participant to mute.
@@ -1271,6 +1314,7 @@ JitsiConference.prototype.onMemberJoined = function(
1271 1314
         error => logger.warn(`Failed to discover features of ${jid}`, error));
1272 1315
 
1273 1316
     this._maybeStartOrStopP2P();
1317
+    this._maybeSetSITimeout();
1274 1318
 };
1275 1319
 
1276 1320
 /* eslint-enable max-params */
@@ -1330,6 +1374,7 @@ JitsiConference.prototype.onMemberLeft = function(jid) {
1330 1374
     }
1331 1375
 
1332 1376
     this._maybeStartOrStopP2P(true /* triggered by user left event */);
1377
+    this._maybeClearSITimeout();
1333 1378
 };
1334 1379
 
1335 1380
 /**
@@ -1580,6 +1625,7 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(
1580 1625
             createJingleEvent(ACTION_JINGLE_RESTART, { p2p: false }));
1581 1626
     }
1582 1627
 
1628
+    this._maybeClearSITimeout();
1583 1629
     Statistics.sendAnalytics(createJingleEvent(
1584 1630
         ACTION_JINGLE_SI_RECEIVED,
1585 1631
         {

+ 8
- 0
service/statistics/AnalyticsEvents.js Ver fichero

@@ -67,6 +67,14 @@ export const ACTION_JINGLE_SA_TIMEOUT = 'session-accept.timeout';
67 67
  */
68 68
 export const ACTION_JINGLE_SI_RECEIVED = 'session-initiate.received';
69 69
 
70
+/**
71
+ * The "action" value for Jingle events which indicates that a session-initiate
72
+ * not arrived within a timeout (the value is specified in
73
+ * the {@link JingleSessionPC}.
74
+ * @type {string}
75
+ */
76
+export const ACTION_JINGLE_SI_TIMEOUT = 'session-initiate.timeout';
77
+
70 78
 /**
71 79
  * A constant for the "terminate" action for Jingle events. TODO: verify/fix
72 80
  * the documentation)

Loading…
Cancelar
Guardar