Commit 607d7986 authored by JC Brand's avatar JC Brand

Store session per full JID

Otherwise we run into a bug where two tabs with Converse.js share the
same XEP-0198 SM-ID, causing both to go into a reconnection-loop as
the XMPP server switches XEP-0198 sessions between them.

This bug is due to a distinction in how sessionStorage behaves when you
open the existing site in a new tab (e.g. middle-click or
`target="_blank"), as opposed to creating a new tab
and then opening the site in that tab.

In the latter case, the newly created sessionStorage object is empty.
In the former, the contents of sessionStorage of the current page is
copied over to the new page!
parent 54804b5b
...@@ -506,8 +506,10 @@ _converse.initConnection = function () { ...@@ -506,8 +506,10 @@ _converse.initConnection = function () {
async function initUserSession (jid) { async function initUserSession (jid) {
const bare_jid = Strophe.getBareJidFromJid(jid); // XXX: Important to use full JID, otherwise we run into a bug where two
const id = `converse.session-${bare_jid}`; // tabs with share the same XEP-0198 SM-ID, causing them to go into a
// reconnection-loop.
const id = `converse.session-${jid}`;
if (!_converse.session || _converse.session.get('id') !== id) { if (!_converse.session || _converse.session.get('id') !== id) {
_converse.session = new Backbone.Model({id}); _converse.session = new Backbone.Model({id});
_converse.session.browserStorage = new BrowserStorage.session(id); _converse.session.browserStorage = new BrowserStorage.session(id);
......
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