Pārlūkot izejas kodu

Auto-reconnect when the connection drops.

JC Brand 12 gadi atpakaļ
vecāks
revīzija
ba82f7bbce
2 mainītis faili ar 28 papildinājumiem un 42 dzēšanām
  1. 18 36
      CHANGES.rst
  2. 10 6
      converse.js

+ 18 - 36
CHANGES.rst

@@ -4,46 +4,28 @@ Changelog
 0.4 (Unreleased)
 ----------------
 
-- CSS tweaks: fixed overflowing text in status message and chatrooms list.
-  [jcbrand]
-- Bugfix: Couldn't join chatroom when clicking from a list of rooms.
-  [jcbrand]
-- Add better support for kicking or banning users from chatrooms.
-  [jcbrand]
-- Fixed alignment of chat messages in Firefox.
-  [jcbrand]
-- More intelligent fetching of vCards.
-  [jcbrand]
-- Fixed a race condition bug. Make sure that the roster is populated before
-  sending initial presence.
-  [jcbrand]
+- CSS tweaks: fixed overflowing text in status message and chatrooms list. [jcbrand]
+- Bugfix: Couldn't join chatroom when clicking from a list of rooms. [jcbrand]
+- Add better support for kicking or banning users from chatrooms. [jcbrand]
+- Fixed alignment of chat messages in Firefox. [jcbrand]
+- More intelligent fetching of vCards. [jcbrand]
+- Fixed a race condition bug. Make sure that the roster is populated before sending initial presence. [jcbrand]
+- Reconnect automatically when the connection drops. [jcbrand]
 
 0.3 (2013-05-21)
 ----------------
 
-- Add vCard support
-  [jcbrand]
-- Remember custom status messages upon reload.
-  [jcbrand]
-- Remove jquery-ui dependency.
-  [jcbrand]
-- Use backbone.localStorage to store the contacts roster, open chatboxes and
-  chat messages.
-  [jcbrand]
-- Fixed user status handling, which wasn't 100% according to the spec.
-  [jcbrand]
-- Separate messages according to day in chats.
-  [jcbrand]
-- Add support for specifying the BOSH bind URL as configuration setting.
-  [jcbrand]
-- Improve the message counter to only increment when the window is not focused
-  [witekdev]
-- Make fetching of list of chatrooms on a server a configuration option.
-  [jcbrand]
-- Use service discovery to show all available features on a room.
-  [jcbrand]
-- Multi-user chatrooms are now configurable.
-  [jcbrand]
+- Add vCard support [jcbrand]
+- Remember custom status messages upon reload. [jcbrand]
+- Remove jquery-ui dependency. [jcbrand]
+- Use backbone.localStorage to store the contacts roster, open chatboxes and chat messages. [jcbrand]
+- Fixed user status handling, which wasn't 100% according to the spec. [jcbrand]
+- Separate messages according to day in chats. [jcbrand]
+- Add support for specifying the BOSH bind URL as configuration setting. [jcbrand]
+- Improve the message counter to only increment when the window is not focused [witekdev]
+- Make fetching of list of chatrooms on a server a configuration option. [jcbrand]
+- Use service discovery to show all available features on a room. [jcbrand]
+- Multi-user chatrooms are now configurable. [jcbrand]
 
 
 0.2 (2013-03-28)

+ 10 - 6
converse.js

@@ -2464,28 +2464,32 @@
             '<input type="text" id="bosh_service_url">'),
 
         connect: function ($form, jid, password) {
-            var $button = $form.find('input[type=submit]'),
+            var button = null,
                 connection = new Strophe.Connection(converse.bosh_service_url);
-            $button.hide().after('<img class="spinner login-submit" src="images/spinner.gif"/>');
+            if ($form) {
+                $button = $form.find('input[type=submit]');
+                $button.hide().after('<img class="spinner login-submit" src="images/spinner.gif"/>');
+            }
             connection.connect(jid, password, $.proxy(function (status, message) {
                 if (status === Strophe.Status.CONNECTED) {
                     console.log('Connected');
                     converse.onConnected(connection);
                 } else if (status === Strophe.Status.DISCONNECTED) {
-                    $button.show().siblings('img').remove();
+                    if ($button) { $button.show().siblings('img').remove(); }
                     converse.giveFeedback('Disconnected', 'error');
+                    this.connect(null, connection.jid, connection.pass);
                 } else if (status === Strophe.Status.Error) {
-                    $button.show().siblings('img').remove();
+                    if ($button) { $button.show().siblings('img').remove(); }
                     converse.giveFeedback('Error', 'error');
                 } else if (status === Strophe.Status.CONNECTING) {
                     converse.giveFeedback('Connecting');
                 } else if (status === Strophe.Status.CONNFAIL) {
-                    $button.show().siblings('img').remove();
+                    if ($button) { $button.show().siblings('img').remove(); }
                     converse.giveFeedback('Connection Failed', 'error');
                 } else if (status === Strophe.Status.AUTHENTICATING) {
                     converse.giveFeedback('Authenticating');
                 } else if (status === Strophe.Status.AUTHFAIL) {
-                    $button.show().siblings('img').remove();
+                    if ($button) { $button.show().siblings('img').remove(); }
                     converse.giveFeedback('Authentication Failed', 'error');
                 } else if (status === Strophe.Status.DISCONNECTING) {
                     converse.giveFeedback('Disconnecting', 'error');