Get JID and Service info when Strophe attaches a session#69
Get JID and Service info when Strophe attaches a session#69WasserX wants to merge 1 commit intometajack:masterfrom
Conversation
|
Hi Do you use this for BOSH prebinding? Do you mind sharing additional bits of code? Example usage would be great. |
|
So, I use sessionStorage and my objective is that if you reload the page, you do not start a new connection, so the code is more or less like this: this.conn = new Strophe.Connection(this.options.gateway.bosh.endpoint); //Snippets of code for understanding
if(!force && typeof sessionStorage.getItem('JID') === 'string'){
sessionStorage.setItem('RID', parseInt(sessionStorage.getItem('RID'))+1);
this.conn.attach(
sessionStorage.getItem('JID'),
sessionStorage.getItem('SID'),
sessionStorage.getItem('RID'),
this.onStatus.bind(this),
null, null, null)
} else{
this.conn.connect(
this.options.username,
this.options.password,
this.onStatus.bind(this),
null, null, null);
}The function onStatus is called whenever the status changes. When we do an attach, onStatus receives So, once I receive an The problem is that once i'm reattached and I try to do a 'subscribe' op, the JID inside |
The function onStatus of the pubsub plugin sets the JID and Service vars needed for executing actions when Strophe sends an status of CONNECTED.
If the user is reattaching / attaching to an existing session, those variables are not initialized.
This commit makes it possible to update those variables when Strophe reports the status ATTACHED.