Ok, well first let me explain. I have a framework that is centered around streaming. However, in the case of Chrome, there is no way to stream. I have to fall back to long polling for Chrome. I dont know if this true for 4 but for 3.x it is. The way we suspend is (at least as it was in 1.9.9 which Im still using, as the later versions have problems with streaming)
Let me explain the framework briefly, it's an asynchronous streaming frame with a semi IOC aspect. I use standard post to issue commands and every client has a tethered connection to the server that the framework responds on. This was innovative when I started back before Grizzly even supported cometd :)
heres the code that I use in the event that I have to fall back to long polling.
1. the connection
-----------
new CometHandlerImpl(session, this.UA, response);
Every session has a sessionContainer that brokers its client state with the system. When a connection is made and I instanate this handler it registers it's self with the session controllers Context handler.
2. After push
---------------------------
public void doRemoveCometHandler(){
try{
// block write queue... so we can tank this guy without collision
this.setCometHandlerBusy(true);
if(this.cometHandler != null){
if(this.SessionContext != null && this.SessionContext.isActive(this.cometHandler))
if(this.cometHandler != null) this.SessionContext.removeCometHandler(this.cometHandler);
// make null so we expedite GC
this.cometHandler = null;
}
// Tell the system that I cant talk to the client
this.ConnectionStatus.setDisconnect();
}catch(Exception e){
e.printStackTrace();
}
}
As you can see, this is somewhat inefficient, Actually this is about as inefficient as it gets. Long polling Comet is on its death bed and streaming is waiting to take over. Till then I need to squeeze more out of the frame than this. Have we implemented a way to suspend the connection handler object that lets it just discard the ServletResponse object and not have to be constantly re-instanated since 1.9.9?