Browse Source

Don't send CSI or auto_away/xa stanzas when not auth'd

This is to deal with reconnects. Originally @thierrytiti checked for
`connection.connected` but I think that might still pose a problem when
reconnecting is in process and the user is not yet authenticated again.

This makes pull request #426 unnecessary.
JC Brand 10 years ago
parent
commit
21a3b44050
1 changed files with 15 additions and 2 deletions
  1. 15 2
      converse.js

+ 15 - 2
converse.js

@@ -426,10 +426,15 @@
         };
         };
 
 
         this.onUserActivity = function () {
         this.onUserActivity = function () {
-            /* Reset counters and flags relating to user activity. */
+            /* Resets counters and flags relating to CSI and auto_away/auto_xa */
             if (this.idle_seconds > 0) {
             if (this.idle_seconds > 0) {
                 this.idle_seconds = 0;
                 this.idle_seconds = 0;
             }
             }
+            if (!converse.connection.authenticated) {
+                // We can't send out any stanzas when there's no authenticated connection.
+                // This can happen when the connection reconnects.
+                return;
+            }
             if (this.inactive) {
             if (this.inactive) {
                 this.sendCSI(ACTIVE);
                 this.sendCSI(ACTIVE);
             }
             }
@@ -440,7 +445,15 @@
         };
         };
 
 
         this.onEverySecond = function () {
         this.onEverySecond = function () {
-            /* An interval handler running every second */
+            /* An interval handler running every second.
+             * Used for CSI and the auto_away and auto_xa
+             * features.
+             */
+            if (!converse.connection.authenticated) {
+                // We can't send out any stanzas when there's no authenticated connection.
+                // This can happen when the connection reconnects.
+                return;
+            }
             var stat = this.xmppstatus.getStatus();
             var stat = this.xmppstatus.getStatus();
             this.idle_seconds++;
             this.idle_seconds++;
             if (this.idle_seconds > this.csi_waiting_time && !this.inactive) {
             if (this.idle_seconds > this.csi_waiting_time && !this.inactive) {