/** * Resume the Comet request and remove it from the active {@link CometHandler} list. Once resumed, * a CometHandler must never manipulate the <code>HttpServletRequest</code> or <code>HttpServletResponse</code> as * those object will be recycled and may be re-used to serve another request. * * If you cache them for later reuse by another thread there is a * possibility to introduce corrupted responses next time a request is made. * @param handler The CometHandler to resume. * @return <tt>true</tt> if the operation succeeded. */ public void resumeCometHandler(CometHandler handler) { super.resumeCometHandler(wrapCometHandler(handler)); }
/** * Resume the underlying response, * @param req an {@link HttpServletRequest} * @param ctx a {@link CometContext} */ private void resume(HttpServletRequest req, CometContext ctx){ CometHandler handler = ctx .getCometHandler((Integer)req.getSession().getAttribute(ATMOSPHERE)); req.getSession().removeAttribute(ATMOSPHERE); if (handler != null){ ctx.resumeCometHandler(handler); } }
/** * Invoked when a {@link CometContext#notify} is executing a push. * @param event * @throws java.io.IOException */ public void onEvent(CometEvent event) throws IOException { if (event.getType() == CometEvent.NOTIFY) { String output = (String) event.attachment(); response.getWriter().println(output); response.getWriter().flush(); if (cometType == CometType.LONG_POLLING){ cometContext.resumeCometHandler(this); } } }
ended = deliverRes.isLast(); if (deliverRes.isFinished()){ event.getCometContext().resumeCometHandler(this); ended = true; event.getCometContext().resumeCometHandler(this);