Subject: [hybi] Basic question about WS and different browser windows

From: Iñaki Baz Castillo <[email-masked]>
Date: Tue, 17 May 2011 14:48:57 +0200

Hi, perhaps this question does not fit well in this maillist, sorry for that.

Imagine a web-chat application (similar to Gmail chat) in which
different <div> are created for each chat session within the main
page. Previously the JavaScript in such page has opened a WS
connection with the server which is used for the chat messages.

Gmail allows opening a chat window into a separate/new windows (a new
browser window, with small size). If we do the same, would it be
needed to open a new WS connection from the new browser window? or
could it share the same connection? (I expect this purely depends on
how JavaScript works....).

Or perhaps there would be a single WS connection from the main page,
such page would receive new WS messages and could update the HTML of
the other window?

Just wondering. Thanks a lot.

-- 
Iñaki Baz Castillo
<[email-masked]>

---

From: Greg Wilkins <[email-masked]>
Date: Wed, 18 May 2011 16:11:18 +1000

Iñaki,

I think this is a question for the W3C/WHATWG working groups on websockets.

However,  expect the answer to your question is going to be tied up in
the shared workers mechanism and I have heard it suggested before that
for such applications you should arrange for a shared worker to open
the WS connection rather than the div itself.

My own preference would be that browsers used a MUX system, so that
individual frames could open WS connections without any knowledge of
how they mapped to TCP/IP connection.  So instead of having to
explicitly talk to a shared worker to get it to send/receive datagrams
on your behalf, you would just use the standard WS javascript API and
the MUX extension would work behind the scenes to transport that over
a shared connection.

cheers

On 17 May 2011 22:48, Iñaki Baz Castillo <[email-masked]> wrote:
> _______________________________________________
> hybi mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/hybi
>

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Wed, 18 May 2011 10:28:51 +0200

> the MUX extension would work behind the scenes to transport that over

Thanks. In this case, could the messages received via a single WS
connection arrive to two separate windows of the web browser?
Interesting stuf here, there are lot of possibilities, but maybe there
should be less :)

Thanks.

-- 
Iñaki Baz Castillo
<[email-masked]>

---

From: Ivan Žužak <[email-masked]>
Date: Wed, 18 May 2011 11:15:57 +0200

> the WS connection rather than the div itself.

This is a nit pick (and for a different discussion list) but ... since
both the main window and the newly created chat window have the same
origin ("https://mail.gmail.com/"), aren't there simpler ways of
passing data from the main window to the new one? Since the main
window has a reference to the newly created window, it can just write
data to that new window's body directly (same-origin policy would
allow it). However, in general, if the windows were on different
origins, then still you could go about it more simply than using
shared workers -- by postMessage-ing data to the new window (since
still you'd have a reference to it from the main window).

Cheers,
Ivan

---

From: Iñaki Baz Castillo <[email-masked]>
Date: Wed, 18 May 2011 21:08:59 +0200

2011/5/18 Ivan Žužak <[email-masked]>:
> Since the main
> allow it).

I expect JavaScript allows that, but I'm not an expert in JavaScript :)

Thanks for the explanation.

-- 
Iñaki Baz Castillo
<[email-masked]>