Ver código fonte

Merge pull request #536 from jitsi/p2p_disabled

Fix when P2P disabled in config
dev1
Saúl Ibarra Corretgé 8 anos atrás
pai
commit
c132c2e964
1 arquivos alterados com 33 adições e 7 exclusões
  1. 33
    7
      JitsiConference.js

+ 33
- 7
JitsiConference.js Ver arquivo

@@ -302,6 +302,27 @@ JitsiConference.prototype.isJoined = function() {
302 302
     return this.room && this.room.joined;
303 303
 };
304 304
 
305
+/**
306
+ * Tells whether or not the P2P mode is enabled in the configuration.
307
+ * @return {boolean}
308
+ */
309
+JitsiConference.prototype.isP2PEnabled = function() {
310
+    return Boolean(this.options.config.p2p && this.options.config.p2p.enabled)
311
+
312
+        // FIXME: remove once we have a default config template. -saghul
313
+        || typeof this.options.config.p2p === 'undefined';
314
+};
315
+
316
+/**
317
+ * When in P2P test mode, the conference will not automatically switch to P2P
318
+ * when there 2 participants.
319
+ * @return {boolean}
320
+ */
321
+JitsiConference.prototype.isP2PTestModeEnabled = function() {
322
+    return Boolean(this.options.config.testing
323
+        && this.options.config.testing.p2pTestMode);
324
+};
325
+
305 326
 /**
306 327
  * Leaves the conference.
307 328
  * @returns {Promise}
@@ -1306,6 +1327,13 @@ JitsiConference.prototype.onIncomingCall
1306 1327
                     reasonMsg: 'P2P not supported',
1307 1328
                     errorMsg: 'This client does not support P2P connections'
1308 1329
                 });
1330
+        } else if (!this.isP2PEnabled() && !this.isP2PTestModeEnabled()) {
1331
+            this._rejectIncomingCall(
1332
+                jingleSession, {
1333
+                    reasonTag: 'decline',
1334
+                    reasonMsg: 'P2P disabled',
1335
+                    errorMsg: 'P2P mode disabled in the configuration'
1336
+                });
1309 1337
         } else if (this.p2pJingleSession) {
1310 1338
             // Reject incoming P2P call (already in progress)
1311 1339
             this._rejectIncomingCall(
@@ -1467,8 +1495,8 @@ JitsiConference.prototype._rejectIncomingCall
1467 1495
                 'An error occurred while trying to terminate'
1468 1496
                     + ' invalid Jingle session', error);
1469 1497
         }, {
1470
-            reason: options.reasonTag,
1471
-            reasonDescription: options.reasonMsg,
1498
+            reason: options && options.reasonTag,
1499
+            reasonDescription: options && options.reasonMsg,
1472 1500
             sendSessionTerminate: true
1473 1501
         });
1474 1502
 };
@@ -2299,11 +2327,9 @@ JitsiConference.prototype._suspendMediaTransferForJvbConnection = function() {
2299 2327
  * @private
2300 2328
  */
2301 2329
 JitsiConference.prototype._maybeStartOrStopP2P = function(userLeftEvent) {
2302
-    if (!(RTCBrowserType.isP2PSupported()
2303
-            && ((this.options.config.p2p && this.options.config.p2p.enabled)
2304
-
2305
-            // FIXME: remove once we have a default config template. -saghul
2306
-            || typeof this.options.config.p2p === 'undefined'))) {
2330
+    if (!RTCBrowserType.isP2PSupported()
2331
+        || !this.isP2PEnabled()
2332
+        || this.isP2PTestModeEnabled()) {
2307 2333
         logger.info('Auto P2P disabled');
2308 2334
 
2309 2335
         return;

Carregando…
Cancelar
Salvar