Explorar o código

Add new event noResumeableSession

JC Brand %!s(int64=10) %!d(string=hai) anos
pai
achega
64847bcb96
Modificáronse 3 ficheiros con 10 adicións e 3 borrados
  1. 6 3
      converse.js
  2. 2 0
      docs/CHANGES.rst
  3. 2 0
      docs/source/index.rst

+ 6 - 3
converse.js

@@ -4563,7 +4563,6 @@
                         throw('If you set prebind=true, you MUST supply JID, RID and SID values');
                     }
                     this.connection.attach(this.jid, this.sid, this.rid, this.onConnect);
-                    return;
                 }
                 if (this.keepalive) {
                     rid = this.session.get('rid');
@@ -4574,7 +4573,9 @@
                         rid += 1;
                         this.session.save({rid: rid}); // The RID needs to be increased with each request.
                         this.connection.attach(jid, sid, rid, this.onConnect);
-                        return;
+                    } else {
+                        delete this.connection;
+                        this.emit('noResumeableSession');
                     }
                 }
             }
@@ -4609,7 +4610,9 @@
             this.otr = new this.OTR();
             this.initSession();
             this.initConnection();
-            this.addControlBox();
+            if (this.connection) {
+                this.addControlBox();
+            }
             return this;
         };
 

+ 2 - 0
docs/CHANGES.rst

@@ -6,6 +6,8 @@ Changelog
 
 * Bugfix. Error when trying to use prebind and keepalive together. [jcbrand]
 * Bugfix. Cannot read property "top" of undefined. [jcbrand]
+* Add new event, noResumeableSession, for when keepalive=true and there aren't
+  any prebind session tokens. [jcbrand]
 
 0.8.3 (2014-09-22)
 ------------------

+ 2 - 0
docs/source/index.rst

@@ -781,6 +781,8 @@ Here are the different events that are emitted:
 +----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
 | **messageSend**                  | When a message will be sent out.                                                                  | ``converse.on('messageSend', function (messageText) { ... });``                         |
 +----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
+| **noResumeableSession**          | When keepalive=true but there aren't any stored prebind tokens.                                   | ``converse.on('noResumeableSession', function () { ... });``                            |
++----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
 | **roster**                       | When the roster is updated.                                                                       | ``converse.on('roster', function (items) { ... });``                                    |
 +----------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
 | **callButtonClicked**            | When a call button (i.e. with class .toggle-call) on a chat box has been clicked.                 | ``converse.on('callButtonClicked', function (connection, model) { ... });``             |