From c95c46edacb6905bc8739ec3603046c91ec51474 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Tue, 25 Oct 2016 15:37:22 -0500 Subject: [PATCH 1/2] feat(conference): reload the page when XMPP connection is dropped --- conference.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/conference.js b/conference.js index 620287dc5..f60979291 100644 --- a/conference.js +++ b/conference.js @@ -18,6 +18,7 @@ import {reportError} from './modules/util/helpers'; import UIUtil from './modules/UI/util/UIUtil'; +const ConnectionEvents = JitsiMeetJS.events.connection; const ConnectionErrors = JitsiMeetJS.errors.connection; const ConferenceEvents = JitsiMeetJS.events.conference; @@ -515,6 +516,7 @@ export default { }).then(([tracks, con]) => { console.log('initialized with %s local tracks', tracks.length); APP.connection = connection = con; + this._bindConnectionFailedHandler(con); this._createRoom(tracks); this.isDesktopSharingEnabled = JitsiMeetJS.isDesktopSharingEnabled(); @@ -551,6 +553,28 @@ export default { isLocalId (id) { return this.getMyUserId() === id; }, + /** + * Binds a handler that will handle the case when the connection is dropped + * in the middle of the conference. + * @param {JitsiConnection} connection the connection to which the handler + * will be bound to. + * @private + */ + _bindConnectionFailedHandler (connection) { + const handler = function (error, errMsg) { + if (ConnectionErrors.OTHER_ERROR === error) { + // - item-not-found + // - connection dropped(closed by Strophe unexpectedly + // possible due too many transport errors) + console.error("XMPP connection error: " + errMsg); + APP.UI.showPageReloadOverlay(); + connection.removeEventListener( + ConnectionEvents.CONNECTION_FAILED, handler); + } + }; + connection.addEventListener( + ConnectionEvents.CONNECTION_FAILED, handler); + }, /** * Simulates toolbar button click for audio mute. Used by shortcuts and API. * @param mute true for mute and false for unmute. From 3c6d464b32a5cd7f7ea1eed2c6be1dcadda35c24 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Tue, 25 Oct 2016 15:50:38 -0500 Subject: [PATCH 2/2] feat(PageReload): make the reload interval random, between 10-30 sec --- modules/UI/UI.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 64690b411..a8f44ab6f 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -21,6 +21,7 @@ import SettingsMenu from "./side_pannels/settings/SettingsMenu"; import Profile from "./side_pannels/profile/Profile"; import Settings from "./../settings/Settings"; import RingOverlay from "./ring_overlay/RingOverlay"; +import RandomUtil from "../util/RandomUtil"; import UIErrors from './UIErrors'; var EventEmitter = require("events"); @@ -1046,7 +1047,7 @@ UI.updateDTMFSupport = function (isDTMFSupported) { * @returns {Promise} Resolved with value - false if the dialog is enabled and * resolved with true if the dialog is disabled or the feedback was already * submitted. Rejected if another dialog is already displayed. This values are - * used to display or not display the thank you dialog from + * used to display or not display the thank you dialog from * conference.maybeRedirectToWelcomePage method. */ UI.requestFeedbackOnHangup = function () { @@ -1103,7 +1104,8 @@ UI.notifyFocusDisconnected = function (focus, retrySec) { * the page should be reloaded. */ UI.showPageReloadOverlay = function () { - PageReloadOverlay.show(15 /* will reload in 15 seconds */); + // Reload the page after 10 - 30 seconds + PageReloadOverlay.show(10 + RandomUtil.randomInt(0, 20)); }; /**