Browse Source

Prevent converse.connection.attach from being called twice

when using prebind and keepalive together.
JC Brand 10 years ago
parent
commit
896b147a40
1 changed files with 9 additions and 9 deletions
  1. 9 9
      converse.js

+ 9 - 9
converse.js

@@ -5332,15 +5332,6 @@
                 }
                 this.setUpXMLLogging();
 
-                if (this.prebind) {
-                    if (this.jid && this.sid && this.rid) {
-                        this.connection.attach(this.jid, this.sid, this.rid, this.onConnect);
-                    }
-                    if (!this.keepalive) {
-                        throw("If you use prebind and don't use keepalive, "+
-                              "then you MUST supply JID, RID and SID values");
-                    }
-                }
                 if (this.keepalive) {
                     rid = this.session.get('rid');
                     sid = this.session.get('sid');
@@ -5365,6 +5356,15 @@
                             this.connection.attach(jid, sid, rid, this.onConnect);
                         }
                     }
+
+                // Prebind without keepalive
+                } else if (this.prebind) {
+                    if (this.jid && this.sid && this.rid) {
+                        this.connection.attach(this.jid, this.sid, this.rid, this.onConnect);
+                    } else {
+                        throw("If you use prebind and don't use keepalive, "+
+                            "then you MUST supply JID, RID and SID values");
+                    }
                 }
             }
         };