sstrigler/JSJaC

How to use ejabberd one user session in multiple tabs/widows

Closed this issue · 5 comments

I am creating one web based chat application using jsjac library and ejabberd.
I am facing one problem that once user get login from any browser its work but when I am trying to login with same credentials from other window then it log outs user from previous browser and make him available on current browser.which I think not a good solution.Facebook and gmail handle such type of functionality..I need such type of functionality with jsjac and ejabberd

But this has nothing to do with JSJaC, it is a matter of server configuration. Simply set maximum number of sessions per user in ejabberd.cfg to value greater than 1.

Also, note that you must generate a unique resource for each session (the example client uses constant resource, simply generate a random one instead of what is in the example).

Adding random number does not solved my problem.It just made user login in differnt tabs.
If this user is in chat room then I want user can recieve and send message from all the login tabs/browser to the room.
same as facebook/gmail.
This solution of adding random number to resource doesn't solve this

Adding random resource allows you to login in multiple tabs.
Synchronizing messages between multiple tabs is something you must program yourself and has nothing to do with JSJaC. By default, XMPP server (ejabberd in particular) will forward the message only to one of the resources. Unfortunately, to change this bahaviour, you must write your own extension to ejabberd to allow this (probably by using protocol described in XEP-0280) and also program support for this extension in JSJaC.

Also there is http://xmpp.org/extensions/inbox/shared-bosh.html which would allow to share a session between multiple tabs at the BOSH level. You'd have to implement this on your own regarding ejabberd's BOSH module though.

Closing this issue as it has nothing to do with JSJaC.