Umar Farman wrote:
> Hope everyone is fine.
>
> I would like assistance in this scenario:
>
> I have two cometContexts doing HTTP streaming to various clients.
>
> Clients connect to contexts through making cometHandlers.
>
> For example, if client X want to join context A and B, then he'll make
> two handlers, one will be added to A and the other to B.
>
> What i'm trying to achieve is that if client X is connected to context
> A, now he sends a request to server, asking to change his context from A
> to B, the server should create a new handler (B) for client X, attach
> the handler A's response to handler B. Add handler B in context B, then
> remove the handler A from context A and unregister context A.
You can just re-use the CometHandler added to Context A and drop it to
Context B, and invoke ContextA.removeCometHandler(CometHandlerA,false)
>
> What happens is everything goes on fine at the server side, but the
> client, which was receiving data through conext A and now must receive
> data from context B, does not receive any data.
>
> The issue arrises where I use contextA.removeCometHandler(handler A).
Yes, because the suspended connection get resumed:
> /**
> * Remove a {_at_link CometHandler}. If the continuation (connection)
> * associated with this {_at_link CometHandler} no longer have
> * {_at_link CometHandler} associated to it, it will be resumed by Grizzly
> * by calling {_at_link CometContext#resumeCometHandler()}
> * @return <tt>true</tt> if the operation succeeded.
> */
> public boolean removeCometHandler(CometHandler handler){
You need to explicitly tell Grizzly Comet to not resume when you remove:
> /**
> * Remove a {_at_link CometHandler}. If the continuation (connection)
> * associated with this {_at_link CometHandler} no longer have
> * {_at_link CometHandler} associated to it, it will be resumed.
> * @param handler The CometHandler to remove.
> * @param resume True is the connection can be resumed if no CometHandler
> * are associated with the underlying SelectionKey.
> * @return <tt>true</tt> if the operation succeeded.
> */
> public boolean removeCometHandler(CometHandler handler,boolean resume){
Try that and let us know.
Thanks!
- Jeanfrancois
> After this point, no data is received by the client.
>
> Kindly, assist me in figuring out why this is happening.
>
> Regards,
> Umar Farman
> Software Engineer
> PakVista Technologies Co. (Pvt) Ltd.
> Office No.18, 3rd Floor, Select Center,
> F-11 Markaz - Islamabad.
> Office: +92 51 831 4504-5
> Cell : +92 3333 525 4003
> URL: www.pakvistatech.com <http://www.pakvistatech.com>
> <http://www.pakvistatech.com/>