Переглянути джерело

Enable automatic reconnecting when ``prebind`` and ``prebind_url`` are
specified.

fixes #330
updates #333

JC Brand 10 роки тому
батько
коміт
7cd27a71b3
2 змінених файлів з 12 додано та 3 видалено
  1. 10 3
      converse.js
  2. 2 0
      docs/CHANGES.rst

+ 10 - 3
converse.js

@@ -431,7 +431,6 @@
 
         this.reconnect = function () {
             converse.giveFeedback(__('Reconnecting'), 'error');
-            converse.emit('reconnect');
             if (!converse.prebind) {
                 this.connection.connect(
                     this.connection.jid,
@@ -443,6 +442,10 @@
                     this.connection.hold,
                     this.connection.route
                 );
+            } else if (converse.prebind_url) {
+                this.clearSession();
+                this._tearDown();
+                this.startNewBOSHSession();
             }
         };
 
@@ -479,6 +482,7 @@
                 converse.giveFeedback(__('Authentication Failed'), 'error');
                 converse.connection.disconnect(__('Authentication Failed'));
             } else if (status === Strophe.Status.DISCONNECTING) {
+                // FIXME: what about prebind?
                 if (!converse.connection.connected) {
                     converse.renderLoginPanel();
                 }
@@ -554,8 +558,8 @@
         this.clearSession = function () {
             this.roster.browserStorage._clear();
             this.session.browserStorage._clear();
-            // XXX: this should perhaps go into the beforeunload handler
-            converse.chatboxes.get('controlbox').save({'connected': false});
+            var controlbox = converse.chatboxes.get('controlbox');
+            controlbox.save({'connected': false});
         };
 
         this.setSession = function () {
@@ -5439,6 +5443,9 @@
         'initialize': function (settings, callback) {
             converse.initialize(settings, callback);
         },
+        'disconnect': function () {
+              converse.connection.disconnect();
+        },
         'account': {
             'logout': function () {
                 converse.logOut();

+ 2 - 0
docs/CHANGES.rst

@@ -8,6 +8,8 @@ Changelog
 * New configuration setting ``allow_contact_removal``. [jcbrand]
 * Document that event handlers receive 'event' obj as first arg. [jcbrand]
 * Add a test to check that notifications are played in chat rooms. [jcbrand] 
+* Enable automatic reconnection when ``prebind`` and ``prebind_url`` are
+  specified. [jcbrand]
 * #339 Require the JID to be specified when using ``keepalive`` with
   ``prebind``. Also add a logout API method. [jcbrand]