users@grizzly.java.net

Can't get registerAsyncWrite to work

From: Richard Zschech <richard_at_zschech.net>
Date: Sun, 21 Jun 2009 06:50:49 -0700 (PDT)

I have a test servlet below. I can't seem to get any comet events for async
writes to be generated. I'm guessing I'm missing a step but I can't work it
out based on the documentation. Any help would be appreciated.

public class GrizzlyServlet extends HttpServlet {
        
        private CometContext cometContext;
        
        public void init(ServletConfig config) throws ServletException {
                String topic = config.getServletContext().getContextPath();
                CometEngine cometEngine = CometEngine.getEngine();
                cometContext = cometEngine.register(topic);
                cometContext.setExpirationDelay(-1);
        }
        
        protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
                CometHandlerImpl handler = new CometHandlerImpl();
                handler.attach(response);
                cometContext.addCometHandler(handler);
                cometContext.registerAsyncWrite(handler);
        }
        
        private class CometHandlerImpl implements CometHandler<HttpServletResponse>
{
                private HttpServletResponse response;
                
                public void attach(HttpServletResponse response) {
                        this.response = response;
                }
                
                public void onInitialize(CometEvent event) throws IOException {
                        System.out.println("onInitialize");
                }
                
                public void onInterrupt(CometEvent event) throws IOException {
                        System.out.println("onInterrupt");
                }
                
                public void onTerminate(CometEvent event) throws IOException {
                        System.out.println("onTerminate");
                }
                
                public void onEvent(CometEvent event) throws IOException {
                        System.out.println("onEvent" + event);
                }
        }
}

-- 
View this message in context: http://www.nabble.com/Can%27t-get-registerAsyncWrite-to-work-tp24134470p24134470.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.