Procházet zdrojové kódy

feat(ChatRoom): add 'disableFocus' option

Adds a flag which can be used to disable talking to Jicofo. It's
intended to be used only in jitsi-meet-spot which joins a special room.
master
paweldomas před 6 roky
rodič
revize
5a9fc76739
2 změnil soubory, kde provedl 35 přidání a 17 odebrání
  1. 12
    1
      modules/xmpp/ChatRoom.js
  2. 23
    16
      modules/xmpp/moderator.js

+ 12
- 1
modules/xmpp/ChatRoom.js Zobrazit soubor

@@ -94,6 +94,9 @@ export default class ChatRoom extends Listenable {
94 94
      * @param password
95 95
      * @param XMPP
96 96
      * @param options
97
+     * @param {boolean} options.disableFocus - when set to {@code false} will
98
+     * not invite Jicofo into the room. This is intended to be used only by
99
+     * jitsi-meet-spot.
97 100
      */
98 101
     constructor(connection, jid, password, XMPP, options) {
99 102
         super();
@@ -170,7 +173,15 @@ export default class ChatRoom extends Listenable {
170 173
         this.password = password;
171 174
 
172 175
         return new Promise(resolve => {
173
-            this.moderator.allocateConferenceFocus(() => {
176
+            this.options.disableFocus
177
+                && logger.info('Conference focus disabled');
178
+
179
+            const preJoin
180
+                = this.options.disableFocus
181
+                    ? Promise.resolve()
182
+                    : this.moderator.allocateConferenceFocus();
183
+
184
+            preJoin.then(() => {
174 185
                 this.sendPresence(true);
175 186
                 resolve();
176 187
             });

+ 23
- 16
modules/xmpp/moderator.js Zobrazit soubor

@@ -363,22 +363,26 @@ Moderator.prototype.parseConfigOptions = function(resultIq) {
363 363
  *
364 364
  * @param {Function} callback - the function to be called back upon the
365 365
  * successful allocation of the conference focus
366
+ * @returns {Promise} - Resolved when Jicofo allows to join the room. It's never
367
+ * rejected and it'll keep on pinging Jicofo forever.
366 368
  */
367
-Moderator.prototype.allocateConferenceFocus = function(callback) {
368
-    // Try to use focus user JID from the config
369
-    this.setFocusUserJid(this.options.connection.focusUserJid);
369
+Moderator.prototype.allocateConferenceFocus = function() {
370
+    return new Promise(resolve => {
371
+        // Try to use focus user JID from the config
372
+        this.setFocusUserJid(this.options.connection.focusUserJid);
370 373
 
371
-    // Send create conference IQ
372
-    this.connection.sendIQ(
373
-        this.createConferenceIq(),
374
-        result => this._allocateConferenceFocusSuccess(result, callback),
375
-        error => this._allocateConferenceFocusError(error, callback));
376
-
377
-    // XXX We're pressed for time here because we're beginning a complex and/or
378
-    // lengthy conference-establishment process which supposedly involves
379
-    // multiple RTTs. We don't have the time to wait for Strophe to decide to
380
-    // send our IQ.
381
-    this.connection.flush();
374
+        // Send create conference IQ
375
+        this.connection.sendIQ(
376
+            this.createConferenceIq(),
377
+            result => this._allocateConferenceFocusSuccess(result, resolve),
378
+            error => this._allocateConferenceFocusError(error, resolve));
379
+
380
+        // XXX We're pressed for time here because we're beginning a complex
381
+        // and/or lengthy conference-establishment process which supposedly
382
+        // involves multiple RTTs. We don't have the time to wait for Strophe to
383
+        // decide to send our IQ.
384
+        this.connection.flush();
385
+    });
382 386
 };
383 387
 
384 388
 /**
@@ -463,7 +467,9 @@ Moderator.prototype._allocateConferenceFocusError = function(error, callback) {
463 467
 
464 468
     // Reset response timeout
465 469
     this.getNextTimeout(true);
466
-    window.setTimeout(() => this.allocateConferenceFocus(callback), waitMs);
470
+    window.setTimeout(
471
+        () => this.allocateConferenceFocus().then(callback),
472
+        waitMs);
467 473
 };
468 474
 
469 475
 /**
@@ -495,7 +501,8 @@ Moderator.prototype._allocateConferenceFocusSuccess = function(
495 501
         const waitMs = this.getNextTimeout();
496 502
 
497 503
         logger.info(`Waiting for the focus... ${waitMs}`);
498
-        window.setTimeout(() => this.allocateConferenceFocus(callback),
504
+        window.setTimeout(
505
+            () => this.allocateConferenceFocus().then(callback),
499 506
             waitMs);
500 507
     }
501 508
 };

Načítá se…
Zrušit
Uložit