Uses separate exp backoff timers for 'not ready' and error responses from the focus.

This commit is contained in:
paweldomas 2014-11-28 16:18:31 +01:00
parent 84a453597c
commit 285096cc99
1 changed files with 11 additions and 2 deletions

View File

@ -7,6 +7,7 @@
var Moderator = (function (my) { var Moderator = (function (my) {
var getNextTimeout = Util.createExpBackoffTimer(1000); var getNextTimeout = Util.createExpBackoffTimer(1000);
var getNextErrorTimeout = Util.createExpBackoffTimer(1000);
my.isModerator = function () { my.isModerator = function () {
return connection.emuc.isModerator(); return connection.emuc.isModerator();
@ -58,12 +59,15 @@ var Moderator = (function (my) {
"Focus has left the room - leaving conference"); "Focus has left the room - leaving conference");
//hangUp(); //hangUp();
// We'd rather reload to have everything re-initialized // We'd rather reload to have everything re-initialized
// FIXME: show some message before reload
location.reload(); location.reload();
} }
} }
); );
}; };
// FIXME: we need to show the fact that we're waiting for the focus
// to the user(or that focus is not available)
my.allocateConferenceFocus = function (roomName, callback) { my.allocateConferenceFocus = function (roomName, callback) {
var elem = $iq({to: config.hosts.focus, type: 'set'}); var elem = $iq({to: config.hosts.focus, type: 'set'});
elem.c('conference', { elem.c('conference', {
@ -74,12 +78,15 @@ var Moderator = (function (my) {
connection.sendIQ(elem, connection.sendIQ(elem,
function (result) { function (result) {
if ('true' === $(result).find('conference').attr('ready')) { if ('true' === $(result).find('conference').attr('ready')) {
// Reset timer // Reset both timers
getNextTimeout(true); getNextTimeout(true);
getNextErrorTimeout(true);
callback(); callback();
} else { } else {
var waitMs = getNextTimeout(); var waitMs = getNextTimeout();
console.info("Waiting for the focus... " + waitMs); console.info("Waiting for the focus... " + waitMs);
// Reset error timeout
getNextErrorTimeout(true);
window.setTimeout( window.setTimeout(
function () { function () {
Moderator.allocateConferenceFocus(roomName, callback); Moderator.allocateConferenceFocus(roomName, callback);
@ -87,8 +94,10 @@ var Moderator = (function (my) {
} }
}, },
function (error) { function (error) {
var waitMs = getNextTimeout(); var waitMs = getNextErrorTimeout();
console.error("Focus error, retry after " + waitMs, error); console.error("Focus error, retry after " + waitMs, error);
// Reset response timeout
getNextTimeout(true);
window.setTimeout( window.setTimeout(
function () { function () {
Moderator.allocateConferenceFocus(roomName, callback); Moderator.allocateConferenceFocus(roomName, callback);