feat(conference): reload the page when XMPP connection is dropped

This commit is contained in:
paweldomas 2016-10-25 15:37:22 -05:00
parent 9f10a059ef
commit c95c46edac
1 changed files with 24 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import {reportError} from './modules/util/helpers';
import UIUtil from './modules/UI/util/UIUtil'; import UIUtil from './modules/UI/util/UIUtil';
const ConnectionEvents = JitsiMeetJS.events.connection;
const ConnectionErrors = JitsiMeetJS.errors.connection; const ConnectionErrors = JitsiMeetJS.errors.connection;
const ConferenceEvents = JitsiMeetJS.events.conference; const ConferenceEvents = JitsiMeetJS.events.conference;
@ -515,6 +516,7 @@ export default {
}).then(([tracks, con]) => { }).then(([tracks, con]) => {
console.log('initialized with %s local tracks', tracks.length); console.log('initialized with %s local tracks', tracks.length);
APP.connection = connection = con; APP.connection = connection = con;
this._bindConnectionFailedHandler(con);
this._createRoom(tracks); this._createRoom(tracks);
this.isDesktopSharingEnabled = this.isDesktopSharingEnabled =
JitsiMeetJS.isDesktopSharingEnabled(); JitsiMeetJS.isDesktopSharingEnabled();
@ -551,6 +553,28 @@ export default {
isLocalId (id) { isLocalId (id) {
return this.getMyUserId() === 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. * Simulates toolbar button click for audio mute. Used by shortcuts and API.
* @param mute true for mute and false for unmute. * @param mute true for mute and false for unmute.