Commit 9db289df authored by JC Brand's avatar JC Brand

Bugfix. Automatic anonymous login didn't work if keepalive=false.

parent 6260ba28
...@@ -5517,50 +5517,50 @@ ...@@ -5517,50 +5517,50 @@
this.setUpXMLLogging(); this.setUpXMLLogging();
if (this.keepalive) { if (this.keepalive) {
if (!this.jid) {
throw new Error("initConnection: when using 'keepalive' with 'prebind, you must supply the JID of the current user.");
}
rid = this.session.get('rid'); rid = this.session.get('rid');
sid = this.session.get('sid'); sid = this.session.get('sid');
jid = this.session.get('jid'); jid = this.session.get('jid');
if (this.authentication === "prebind") { }
if (!this.jid) { if (this.authentication === PREBIND) {
throw new Error("initConnection: when using 'keepalive' with 'prebind, you must supply the JID of the current user."); if (!this.keepalive) {
} if (this.jid && this.sid && this.rid) {
if (rid && sid && jid && Strophe.getBareJidFromJid(jid) === Strophe.getBareJidFromJid(this.jid)) { this.connection.attach(this.jid, this.sid, this.rid, this.onConnStatusChanged);
this.session.save({rid: rid}); // The RID needs to be increased with each request.
this.connection.attach(jid, sid, rid, this.onConnStatusChanged);
} else if (this.prebind_url) {
this.startNewBOSHSession();
} else { } else {
delete this.connection; throw new Error("initConnection: If you use prebind and not keepalive, "+
this.emit('noResumeableSession'); "then you MUST supply JID, RID and SID values");
} }
}
if (rid && sid && jid && Strophe.getBareJidFromJid(jid) === Strophe.getBareJidFromJid(this.jid)) {
this.session.save({rid: rid}); // The RID needs to be increased with each request.
this.connection.attach(jid, sid, rid, this.onConnStatusChanged);
} else if (this.prebind_url) {
this.startNewBOSHSession();
} else { } else {
// Non-prebind case. delete this.connection;
if (rid && sid && jid) { this.emit('noResumeableSession');
this.session.save({rid: rid}); // The RID needs to be increased with each request. }
this.connection.attach(jid, sid, rid, this.onConnStatusChanged); } else {
} else if (this.auto_login) { // Non-prebind case.
if (!this.jid) { if (this.keepalive && rid && sid && jid) {
throw new Error("initConnection: If you use auto_login, you also need to provide a jid value"); this.session.save({rid: rid}); // The RID needs to be increased with each request.
} this.connection.attach(jid, sid, rid, this.onConnStatusChanged);
if (this.authentication === ANONYMOUS) { } else if (this.auto_login) {
this.connection.connect(this.jid, null, this.onConnStatusChanged); if (!this.jid) {
} else if (this.authentication === LOGIN) { throw new Error("initConnection: If you use auto_login, you also need to provide a jid value");
if (!this.password) { }
throw new Error("initConnection: If you use auto_login and "+ if (this.authentication === ANONYMOUS) {
"authentication='login' then you also need to provide a password."); this.connection.connect(this.jid, null, this.onConnStatusChanged);
} } else if (this.authentication === LOGIN) {
this.connection.connect(this.jid, this.password, this.onConnStatusChanged); if (!this.password) {
throw new Error("initConnection: If you use auto_login and "+
"authentication='login' then you also need to provide a password.");
} }
this.connection.connect(this.jid, this.password, this.onConnStatusChanged);
} }
} }
} else if (this.authentication == "prebind") {
// prebind is used without keepalive
if (this.jid && this.sid && this.rid) {
this.connection.attach(this.jid, this.sid, this.rid, this.onConnStatusChanged);
} else {
throw new Error("initConnection: If you use prebind and not keepalive, "+
"then you MUST supply JID, RID and SID values");
}
} }
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment