librelist archives

« back to archive

About multi-pages chat window

About multi-pages chat window

From:
Juan Chavat
Date:
2014-09-19 @ 18:22
Hi everyone!

I'm Juan Pablo from Uruguay, I'm trying to develop something with
converse.js.
I would like to ask you about implementation in multiple pages where each
one have a chat window from the same JID.
I read some comments from JC Brand here
<https://github.com/jcbrand/converse.js/issues/41> where he suggest not
using the same
SID for every connection, so I went in this way and I established a new
connection for every new window. Now the problem, since I use the chat
window to send something I receive the next messages just in the last
window I used and not in the others, is there something to fix that?
am I doing something wrong? My bosh server implementation is punjab, is
something with that?
The strage is that before sending the first message, I receive in all the
windows chat.

Thanks in advance for your time!!

Cheers from South America,
Juan Pablo

My convers settings are:

converse.initialize({
                    allow_otr: true,
                    auto_list_rooms: false,
                    auto_subscribe: false,
                    jid: _JID,
                    rid: connection._proto.rid+2,//_RID,
                    sid: _SID,
                    prebind: true,
                    bosh_service_url: BOSH_SERVICE,
                    show_controlbox_by_default: true,
                    debug: true,
                    expose_rid_and_sid: true,
                    roster_groups: true
                });

And I'm binding a connection established just some lines before, from a new
Bosh instance.

Re: [conversejs] About multi-pages chat window

From:
Jc Brand
Date:
2014-09-20 @ 11:06
Hi Juan Pablo

If you are using a different SID for each tab, then each tab is essentially a
different chat client, and each gets it's own identifier (called a "resource").

When you send someone a chat, you can send it to a specific chat client (i.e.
resource) by including the resource in the JID (jabber ID) of the user.

Only that resource/chat-client will then receive the chat, even if other chat
clients (or tabs) are also connected.

So it sounds like what's happening here is that you are receiving a message
addressed to that specific resource.

If it happens only after you have sent a message, then I guess the chat client
on the other side replies specifically to that resource, and therefore only the
tab from which you sent the message receives messages.

Message Carbons are supposed to solve this problem.
http://xmpp.org/extensions/xep-0280.htmll

Make sure to set "message_carbons: true" when you call initialize, and then
your XMPP server must also support them and have that support enabled.

Regards
JC



On Fri, Sep 19, 2014 at 03:22:20PM -0300, Juan Chavat wrote:
>    Hi everyone!
> 
>    I'm Juan Pablo from Uruguay, I'm trying to develop something with
>    converse.js.
>    I would like to ask you about implementation in multiple pages where each
>    one have a chat window from the same JID.
>    I read some comments from JC Brand [1]here where he suggest not using the
>    same
>    SID for every connection, so I went in this way and I established a new
>    connection for every new window. Now the problem, since I use the chat
>    window to send something I receive the next messages just in the last
>    window I used and not in the others, is there something to fix that?
>    am I doing something wrong? My bosh server implementation is punjab, is
>    something with that?
>    The strage is that before sending the first message, I receive in all the
>    windows chat.
>    Thanks in advance for your time!!
> 
>    Cheers from South America,
>    Juan Pablo
> 
>    My convers settings are:
> 
>    converse.initialize({
>                        allow_otr: true,
>                        auto_list_rooms: false,
>                        auto_subscribe: false,
>                        jid: _JID,
>                        rid: connection._proto.rid+2,//_RID,
>                        sid: _SID,
>                        prebind: true,
>                        bosh_service_url: BOSH_SERVICE,
>                        show_controlbox_by_default: true,
>                        debug: true,
>                        expose_rid_and_sid: true,
>                        roster_groups: true
>                    });
> 
>    And I'm binding a connection established just some lines before, from a
>    new Bosh instance.
> 
> References
> 
>    Visible links
>    1. https://github.com/jcbrand/converse.js/issues/41

Re: [conversejs] About multi-pages chat window

From:
Guillaume Deberdt
Date:
2014-09-20 @ 17:17
I'm not an expert but from what I've tested and learnt :

You can't have the same SID for two tabs cause each one will increment its
RID differently and the server will close the session cause of incoherence
in the RID value.

Forward_message, assuming that A sends a message to B, it will send the 
message to A also so if you are able to send message to all tabs, the sent
message will also appear in all A-chat.

If what I've told is false, any correction would be welcomed to better 
understand this.

Le 20 sept. 2014 19:05, Barry Brinster <brinster@digitmedia.com> a écrit :
>
> JC 
>
> I've been following this thread as we are also wanting to see same 
> messages in m

ultiple tabs. > > If that is our goal, should each tab have it's own 
session? > > Or should they share the session and just have different 
RIDs? > > Also, you recommended to Juam Pablo to use Message Carbons > 
(http://xmpp.org/extensions/xep-0280.html) to replicate messages. > > But 
your "forward_messages: true" in Converse should achieve this as > well, 
correct? > > What does "forward_messages: true" do exactly?  > > I assumed
it forwarded the chat to all the RIDs associated with a JID. > > Is that 
correct? > > > > Barry Brinster > 609.286.9223 > > > -------- Original 
Message -------- > > Subject: Re: [conversejs] About multi-pages chat 
window > > From: JC Brand > > Date: Sat, September 20, 2014 7:06 am > > 
To: conversejs@librelist.com > > > > > > Hi Juan Pablo > > > > If you are 
using a different SID for each tab, then each tab is essentially a > > 
different chat client, and each gets it's own identifier (called a 
"resource"). > > > > When you send someone a chat, you can send it to a 
specific chat client (i.e. > > resource) by including the resource in the 
JID (jabber ID) of the user. > > > > Only that resource/chat-client will 
then receive the chat, even if other chat > > clients (or tabs) are also 
connected. > > > > So it sounds like what's happening here is that you are
receiving a message > > addressed to that specific resource. > > > > If it
happens only after you have sent a message, then I guess the chat client >
> on the other side replies specifically to that resource, and therefore 
only the > > tab from which you sent the message receives messages. > > > 
> Message Carbons are supposed to solve this problem. > > 
http://xmpp.org/extensions/xep-0280.htmll > > > > Make sure to set 
"message_carbons: true" when you call initialize, and then > > your XMPP 
server must also support them and have that support enabled. > > > > 
Regards > > JC > > > > > > > > On Fri, Sep 19, 2014 at 03:22:20PM -0300, 
Juan Chavat wrote: > > >    Hi everyone! > > > > > >    I'm Juan Pablo 
from Uruguay, I'm trying to develop something with > > >    converse.js. >
> >    I would like to ask you about implementation in multiple pages 
where each > > >    one have a chat window from the same JID. > > >    I 
read some comments from JC Brand [1]here where he suggest not using the > 
> >    same > > >    SID for every connection, so I went in this way and I
established a new > > >    connection for every new window. Now the 
problem, since I use the chat > > >    window to send something I receive 
the next messages just in the last > > >    window I used and not in the 
others, is there something to fix that? > > >    am I doing something 
wrong? My bosh server implementation is punjab, is > > >    something with
that? > > >    The strage is that before sending the first message, I 
receive in all the > > >    windows chat. > > >    Thanks in advance for 
your time!! > > > > > >    Cheers from South America, > > >    Juan Pablo 
> > > > > >    My convers settings are: > > > > > >    
converse.initialize({ > > >                        allow_otr: true, > > 
>                        auto_list_rooms: false, > > >    
 auto_subscribe: false, > > >                        jid: _JID, > > >    
 rid: connection._proto.rid+2,//_RID, > > >                        sid: 
_SID, > > >                        prebind: true, > > >    
 bosh_service_url: BOSH_SERVICE, > > >                        
show_controlbox_by_default: true, > > >                        debug: 
true, > > >                        expose_rid_and_sid: true, > > >    
 roster_groups: true > > >                    }); > > > > > >    And I'm 
binding a connection established just some lines before, from a > > >    
new Bosh instance. > > > > > > References > > > > > >    Visible links > >
>    1. https://github.com/jcbrand/converse.js/issues/41

Re: [conversejs] About multi-pages chat window

From:
Barry Brinster
Date:
2014-09-20 @ 17:04
JC

I've been following this thread as we are also wanting to see same
messages in multiple tabs.

If that is our goal, should each tab have it's own session?

Or should they share the session and just have different RIDs?

Also, you recommended to Juam Pablo to use Message Carbons
(http://xmpp.org/extensions/xep-0280.html) to replicate messages.

But your "forward_messages: true" in Converse should achieve this as
well, correct?

What does "forward_messages: true" do exactly?  

I assumed it forwarded the chat to all the RIDs associated with a JID.

Is that correct?



Barry Brinster
609.286.9223

> -------- Original Message --------
> Subject: Re: [conversejs] About multi-pages chat window
> From: JC Brand <lists@opkode.com>
> Date: Sat, September 20, 2014 7:06 am
> To: conversejs@librelist.com
> 
> 
> Hi Juan Pablo
> 
> If you are using a different SID for each tab, then each tab is essentially a
> different chat client, and each gets it's own identifier (called a "resource").
> 
> When you send someone a chat, you can send it to a specific chat client (i.e.
> resource) by including the resource in the JID (jabber ID) of the user.
> 
> Only that resource/chat-client will then receive the chat, even if other chat
> clients (or tabs) are also connected.
> 
> So it sounds like what's happening here is that you are receiving a message
> addressed to that specific resource.
> 
> If it happens only after you have sent a message, then I guess the chat client
> on the other side replies specifically to that resource, and therefore only the
> tab from which you sent the message receives messages.
> 
> Message Carbons are supposed to solve this problem.
> http://xmpp.org/extensions/xep-0280.htmll
> 
> Make sure to set "message_carbons: true" when you call initialize, and then
> your XMPP server must also support them and have that support enabled.
> 
> Regards
> JC
> 
> 
> 
> On Fri, Sep 19, 2014 at 03:22:20PM -0300, Juan Chavat wrote:
> >    Hi everyone!
> > 
> >    I'm Juan Pablo from Uruguay, I'm trying to develop something with
> >    converse.js.
> >    I would like to ask you about implementation in multiple pages where each
> >    one have a chat window from the same JID.
> >    I read some comments from JC Brand [1]here where he suggest not using the
> >    same
> >    SID for every connection, so I went in this way and I established a new
> >    connection for every new window. Now the problem, since I use the chat
> >    window to send something I receive the next messages just in the last
> >    window I used and not in the others, is there something to fix that?
> >    am I doing something wrong? My bosh server implementation is punjab, is
> >    something with that?
> >    The strage is that before sending the first message, I receive in all the
> >    windows chat.
> >    Thanks in advance for your time!!
> > 
> >    Cheers from South America,
> >    Juan Pablo
> > 
> >    My convers settings are:
> > 
> >    converse.initialize({
> >                        allow_otr: true,
> >                        auto_list_rooms: false,
> >                        auto_subscribe: false,
> >                        jid: _JID,
> >                        rid: connection._proto.rid+2,//_RID,
> >                        sid: _SID,
> >                        prebind: true,
> >                        bosh_service_url: BOSH_SERVICE,
> >                        show_controlbox_by_default: true,
> >                        debug: true,
> >                        expose_rid_and_sid: true,
> >                        roster_groups: true
> >                    });
> > 
> >    And I'm binding a connection established just some lines before, from a
> >    new Bosh instance.
> > 
> > References
> > 
> >    Visible links
> >    1. https://github.com/jcbrand/converse.js/issues/41

Re: [conversejs] About multi-pages chat window

From:
Jc Brand
Date:
2014-09-21 @ 11:29
On Sat, Sep 20, 2014 at 10:04:49AM -0700, Barry Brinster wrote:
> JC
> 
> I've been following this thread as we are also wanting to see same
> messages in multiple tabs.
> 
> If that is our goal, should each tab have it's own session?

Yes.
  
> Or should they share the session and just have different RIDs?
 
No. Only one RID can be valid at a time, so as soon as a tab has a valid RID,
all the other tabs by definition are out of the session (unless each tab has
its own session).
  
> Also, you recommended to Juam Pablo to use Message Carbons
> (http://xmpp.org/extensions/xep-0280.html) to replicate messages.
> 
> But your "forward_messages: true" in Converse should achieve this as
> well, correct?

Only for out-bound messages, not for inbound messages. With message
carbons, the XMPP server should forward inbound messages to all connected
clients (who have indicated they have support for it).

> What does "forward_messages: true" do exactly?  

forward_messages is a solution I came up with before I knew about
message carbons (and only applies to outbound messages)

It's based on XEP-0297 Stanza Forwarding (which incidentally Message Carbons
also make use of).

Someone else provided message carbon support for converse.js (via a Github pull
request).

Since Message Carbons apply both to inbound and outbound messages, it's the
solution to Juan Pablo's situation.

It's probably best for everyone to consider message_forwarding deprecated,
unless there are very specific use-cases for it (which I'm not aware of ATM).
 
> I assumed it forwarded the chat to all the RIDs associated with a JID.
> 
> Is that correct?
 
It forwards an outbound (i.e. sent) message to all associated chat "resources",
i.e. all other connected chat clients of the same account.

Resources and RIDS are two very different things. The RID is the Request ID,
which is a token unique to each HTTP request the client makes. It's used
together with a Session ID, SID, when communicating over HTTP with a BOSH server.

JC

Re: [conversejs] About multi-pages chat window

From:
Juan Chavat
Date:
2014-09-22 @ 18:23
First of all, Thank you for all of your replays!
Before your replays I was trying a solution attaching and detaching the
connection when the user changes the tab, using cookies to save SID and RID
but I couldn't take control over the Strophe connection that converse.js
established so I couldn't detach and attach it again in every blur/focus js
event trigged by the windows element. Any idea how to do  that?
BTW, I coded a solution using message_carbons flag and mod_carboncopy in
the XMPP server and it worked really well!!!  But I'm still want to try a
solution changing just my javascripts (or the bosh server as second
instance) and not the XMPP.
Thanks again!
Regards,
Jp

2014-09-21 8:29 GMT-03:00 JC Brand <lists@opkode.com>:

> On Sat, Sep 20, 2014 at 10:04:49AM -0700, Barry Brinster wrote:
> > JC
> >
> > I've been following this thread as we are also wanting to see same
> > messages in multiple tabs.
> >
> > If that is our goal, should each tab have it's own session?
>
> Yes.
>
> > Or should they share the session and just have different RIDs?
>
> No. Only one RID can be valid at a time, so as soon as a tab has a valid
> RID,
> all the other tabs by definition are out of the session (unless each tab
> has
> its own session).
>
> > Also, you recommended to Juam Pablo to use Message Carbons
> > (http://xmpp.org/extensions/xep-0280.html) to replicate messages.
> >
> > But your "forward_messages: true" in Converse should achieve this as
> > well, correct?
>
> Only for out-bound messages, not for inbound messages. With message
> carbons, the XMPP server should forward inbound messages to all connected
> clients (who have indicated they have support for it).
>
> > What does "forward_messages: true" do exactly?
>
> forward_messages is a solution I came up with before I knew about
> message carbons (and only applies to outbound messages)
>
> It's based on XEP-0297 Stanza Forwarding (which incidentally Message
> Carbons
> also make use of).
>
> Someone else provided message carbon support for converse.js (via a Github
> pull
> request).
>
> Since Message Carbons apply both to inbound and outbound messages, it's the
> solution to Juan Pablo's situation.
>
> It's probably best for everyone to consider message_forwarding deprecated,
> unless there are very specific use-cases for it (which I'm not aware of
> ATM).
>
> > I assumed it forwarded the chat to all the RIDs associated with a JID.
> >
> > Is that correct?
>
> It forwards an outbound (i.e. sent) message to all associated chat
> "resources",
> i.e. all other connected chat clients of the same account.
>
> Resources and RIDS are two very different things. The RID is the Request
> ID,
> which is a token unique to each HTTP request the client makes. It's used
> together with a Session ID, SID, when communicating over HTTP with a BOSH
> server.
>
> JC
>