Since there is only suggestion threads about this problem's workaround
and general ideas, i propose to create a fully functional workaround
for the multiple sessions issue, so any new users that might be having
problems with it can read up and make it happen.
So, in earlier threads it has been stated that working with 2
connections from the same sessions can wreak havoc on the internal
implementation of CometSession, like <a href="
http://groups.google.com/
group/gwt-comet/browse_thread/thread/4af677f6da363324">Here</a> 2
types of workarounds were implemented.
Icky's suggestion that sounds good
"1) I don't use comet session, I use cometResponse explicitly.
2) Each new browser tab/window is allocated an ID.
3) When connect to CometServlet I save their cometResponse against
that ID
4) When they subscribe/unsusbcribe, I store all subscriptions against
the ID
5) Then when server need to push, it retrieves the saved
cometResponse
associated with the ID and queue messages to it. "
but i failed to make it work since the server wasn't holding on to any
connections and closed them immediately after doing doComet(...) by
sending an error of type "Unexpected Disconnection". So i might be
doing something wrong and i hope someone will correct me if im doing
something wrong
<code>
@Override
protected void doComet(CometServletResponse cometResponse) throws
ServletException, IOException {
System.out.println("Connection Req");
HttpServletRequest request = cometResponse.getRequest();
String cometClientId = request.getParameter("id");
String requestSessionId = request.getSession(true).getId();
StreamingEventHandler.registerListener(cometResponse);
CometServletResponseImpl resp = (CometServletResponseImpl)
cometResponse;
//cometResponse.getSession();
}
</code>
Whereas if i uncomment the last row it works, but by creating a
session witch in return disables multiple instances of tabs.
Other method was mentioned by the owner of this project (Richard)
"A simple possibility would be to change
CometServlet.getCometSession(...) to take the HttpServletRequest
which
you could add a "new connection" parameter too. When the "new
connection" parameter is set then rather than looking up the
CometSession from the HttpSession basked on
CometSession.HTTP_SESSION_KEY you could generate a connection id and
do the HttpSession mapping based on that. You could then return the
connection id back to the client which could use it for subsequent
requests."
This part confuses me a little bit, we need to alter the project to
inject additional parameters into CometSession... I think i have an
idea what you mean but it doesn't hurt to clarify a little bit. So we
will have to change CometSessionImplementation aswell since that
creates the session? Or CometResponseImpl ?
Any help is greatly appreciated, by me and anyone who needs to
overcome this problem.
If we make this work, i would be happy to change the chat application
to work with multiple tabs as an example as well as a token of my
gratitude...
Let's make this happen!