Browse Source

fix(conference.js): handle CONNECTION_DROPPED_ERROR

master
paweldomas 8 years ago
parent
commit
6c716bcbb1
1 changed files with 27 additions and 17 deletions
  1. 27
    17
      conference.js

+ 27
- 17
conference.js View File

@@ -546,24 +546,34 @@ export default {
546 546
      */
547 547
     _bindConnectionFailedHandler (connection) {
548 548
         const handler = function (error, errMsg) {
549
-            if (ConnectionErrors.OTHER_ERROR === error ||
550
-                ConnectionErrors.SERVER_ERROR === error) {
551
-                // - item-not-found
552
-                // - connection dropped(closed by Strophe unexpectedly
553
-                //   possible due too many transport errors)
554
-                const isNetworkFailure
555
-                    = error !== ConnectionErrors.SERVER_ERROR;
556
-                logger.error("XMPP connection error: " + errMsg);
557
-                APP.UI.showPageReloadOverlay(
558
-                    isNetworkFailure,
559
-                    "xmpp-conn-dropped:" + errMsg);
560
-                connection.removeEventListener(
561
-                    ConnectionEvents.CONNECTION_FAILED, handler);
562
-                // FIXME it feels like the conference should be stopped
563
-                // by lib-jitsi-meet
564
-                if (room)
565
-                    room.leave();
549
+            /* eslint-disable no-case-declarations */
550
+            switch (error) {
551
+                case ConnectionErrors.CONNECTION_DROPPED_ERROR:
552
+                case ConnectionErrors.OTHER_ERROR:
553
+                case ConnectionErrors.SERVER_ERROR:
554
+
555
+                    logger.error("XMPP connection error: " + errMsg);
556
+
557
+                    // From all of the cases above only CONNECTION_DROPPED_ERROR
558
+                    // is considered a network type of failure
559
+                    const isNetworkFailure
560
+                        = error === ConnectionErrors.CONNECTION_DROPPED_ERROR;
561
+
562
+                    APP.UI.showPageReloadOverlay(
563
+                        isNetworkFailure,
564
+                        "xmpp-conn-dropped:" + errMsg);
565
+
566
+                    connection.removeEventListener(
567
+                        ConnectionEvents.CONNECTION_FAILED, handler);
568
+
569
+                    // FIXME it feels like the conference should be stopped
570
+                    // by lib-jitsi-meet
571
+                    if (room)
572
+                        room.leave();
573
+
574
+                    break;
566 575
             }
576
+            /* eslint-enable no-case-declarations */
567 577
         };
568 578
         connection.addEventListener(
569 579
             ConnectionEvents.CONNECTION_FAILED, handler);

Loading…
Cancel
Save