Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session handling #119

Merged
merged 8 commits into from
Jun 7, 2015
Merged

Session handling #119

merged 8 commits into from
Jun 7, 2015

Conversation

jcbrand
Copy link
Contributor

@jcbrand jcbrand commented May 31, 2015

The "keepalive" option can be used to instruct Strophe to maintain the current BOSH session across interruptions such as webpage reloads.

It will do this by caching the sessions tokens in sessionStorage, and when connection.restore is called it will check whether there are cached tokens with which it can resume an existing session.

This is how you would use it:

    var connection = new Strophe.Connection(BOSH_SERVICE, {'keepalive': true});
    try {
        connection.restore(jid, callback);
    } catch(e) {
        if (e.name !== "StropheSessionError") { throw(e); }
        # Make ajax call to get new BOSH session tokens and then attach with
        # connection.attach
    }                                                                                                                     

When creating prebound BOSH sessions server-side, it's important to pass in the JID to the connection.restore method. Otherwise one might get sessions restored for the wrong users.

In the manual login case, it's not necessary to pass in the JID.

@jcbrand
Copy link
Contributor Author

jcbrand commented May 31, 2015

Hi @Gordin, let me know whether you have any suggestions on this feature, otherwise I intend to merge it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant