Преглед изворни кода

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 пре 6 година
родитељ
комит
5a9fc76739
2 измењених фајлова са 35 додато и 17 уклоњено
  1. 12
    1
      modules/xmpp/ChatRoom.js
  2. 23
    16
      modules/xmpp/moderator.js

+ 12
- 1
modules/xmpp/ChatRoom.js Прегледај датотеку

94
      * @param password
94
      * @param password
95
      * @param XMPP
95
      * @param XMPP
96
      * @param options
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
     constructor(connection, jid, password, XMPP, options) {
101
     constructor(connection, jid, password, XMPP, options) {
99
         super();
102
         super();
170
         this.password = password;
173
         this.password = password;
171
 
174
 
172
         return new Promise(resolve => {
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
                 this.sendPresence(true);
185
                 this.sendPresence(true);
175
                 resolve();
186
                 resolve();
176
             });
187
             });

+ 23
- 16
modules/xmpp/moderator.js Прегледај датотеку

363
  *
363
  *
364
  * @param {Function} callback - the function to be called back upon the
364
  * @param {Function} callback - the function to be called back upon the
365
  * successful allocation of the conference focus
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
 
467
 
464
     // Reset response timeout
468
     // Reset response timeout
465
     this.getNextTimeout(true);
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
         const waitMs = this.getNextTimeout();
501
         const waitMs = this.getNextTimeout();
496
 
502
 
497
         logger.info(`Waiting for the focus... ${waitMs}`);
503
         logger.info(`Waiting for the focus... ${waitMs}`);
498
-        window.setTimeout(() => this.allocateConferenceFocus(callback),
504
+        window.setTimeout(
505
+            () => this.allocateConferenceFocus().then(callback),
499
             waitMs);
506
             waitMs);
500
     }
507
     }
501
 };
508
 };

Loading…
Откажи
Сачувај