fix(conference.js): handle CONNECTION_DROPPED_ERROR

This commit is contained in:
paweldomas 2016-12-01 15:50:37 -06:00
parent 44beed6216
commit 6c716bcbb1
1 changed files with 27 additions and 17 deletions

View File

@ -546,24 +546,34 @@ export default {
*/ */
_bindConnectionFailedHandler (connection) { _bindConnectionFailedHandler (connection) {
const handler = function (error, errMsg) { const handler = function (error, errMsg) {
if (ConnectionErrors.OTHER_ERROR === error || /* eslint-disable no-case-declarations */
ConnectionErrors.SERVER_ERROR === error) { switch (error) {
// - item-not-found case ConnectionErrors.CONNECTION_DROPPED_ERROR:
// - connection dropped(closed by Strophe unexpectedly case ConnectionErrors.OTHER_ERROR:
// possible due too many transport errors) case ConnectionErrors.SERVER_ERROR:
const isNetworkFailure
= error !== ConnectionErrors.SERVER_ERROR;
logger.error("XMPP connection error: " + errMsg); logger.error("XMPP connection error: " + errMsg);
// From all of the cases above only CONNECTION_DROPPED_ERROR
// is considered a network type of failure
const isNetworkFailure
= error === ConnectionErrors.CONNECTION_DROPPED_ERROR;
APP.UI.showPageReloadOverlay( APP.UI.showPageReloadOverlay(
isNetworkFailure, isNetworkFailure,
"xmpp-conn-dropped:" + errMsg); "xmpp-conn-dropped:" + errMsg);
connection.removeEventListener( connection.removeEventListener(
ConnectionEvents.CONNECTION_FAILED, handler); ConnectionEvents.CONNECTION_FAILED, handler);
// FIXME it feels like the conference should be stopped // FIXME it feels like the conference should be stopped
// by lib-jitsi-meet // by lib-jitsi-meet
if (room) if (room)
room.leave(); room.leave();
break;
} }
/* eslint-enable no-case-declarations */
}; };
connection.addEventListener( connection.addEventListener(
ConnectionEvents.CONNECTION_FAILED, handler); ConnectionEvents.CONNECTION_FAILED, handler);