|
@@ -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
|
};
|