Closed maxguzenski closed 12 years ago
Each tab connects separately even if the JID is the same (the server will assign a unique resource to each instance), so there won't be a broadcast, unless you send messages to the bare JID (user@domain) instead of (user@domain/resource). Either ways, message dispatch is done by the xmpp server and not the bosh proxy.
No, I use a pre-binded , so each tab has same resource.
I'm receiving message on all tabs... that is not the problem. What I'd like to have is a broadcast of message that I SEND from 1 tab, broadcasting to all tabs in same full jid (node@domain/resource).
I solved this issue:
Let me explain , I have a one-to-one chat, pretty same of facebook webchat.
I use Backbone + Backbone.localStorage + Strophe.
Every little change on backbone models, or in Strophe RID, I save it on localStorage.
When user change tab (focus/blur event) I reload my models from localStorage (collection.fetch())
So, everthing looks be in sync, many tabs with one unique full-jid. It is working, I guess ;)
Ah! I see the problem now. If I understand it correctly, you want to be able to show the message that user X has sent in all tabs that user X currently has open right?
You are solving it for the single machine case with local storage, but the same solution won't work if user X has tabs open on multiple machines right?
One way could be to use a custom message type (say "echo") and send it to your own JID and all open tabs will interpret it in a special manner. Another option would be to modify the xmpp server (not always possible if the XMPP server is not in your control). Yet another would be to mod the bosh proxy to echo messages to every bare JID that is the same. You'll probably have to make a few changes since there is no index on JID at the moment. In fact, no user data is every used for tracking in node-xmpp-bosh and it never assumes the presence of a JID. The bosh server approach fails if the user connects via TCP sockets or via another BOSH server that doesn't have this mod.
Either ways, you'll need to make changes to the client (unless it already supports it). Maybe you can take a look at jappix since it is a pretty mature project - maybe they already have this mod.
Hi, If I have 2 attached tabs (chrome) with Strophe.attache ... shouldn't node-xmpp-bosh broadcast all messages sending by tab 1 to tab 2? To keep in sync?