public Set<DataHandler> lookupClientHandlers(String channelId) { final CometContext context = CometEngine.getEngine().getCometContext(channel); if (context != null) { return context.getCometHandlers(); } return Collections.EMPTY_SET; }
/** * {@inheritDoc} */ public void action(AtmosphereEventImpl actionEvent){ if (actionEvent.action().type == Action.TYPE.RESUME){ CometContext ctx = CometEngine.getEngine().getCometContext(atmosphereCtx); resume(actionEvent.getRequest(), ctx); } }
/** * Init Grizzly's {@link CometContext} that will be used to suspend and * resume the response. * @param sc the {@link ServletContext} * @throws javax.servlet.ServletException */ @Override public void init(ServletConfig sc) throws ServletException{ super.init(sc); atmosphereCtx = sc.getServletContext().getContextPath() + ATMOSPHERE; CometEngine cometEngine = CometEngine.getEngine(); CometContext context = cometEngine.register(atmosphereCtx); context.setExpirationDelay(-1); if (logger.isLoggable(Level.FINE)){ logger.fine("Created CometContext for " + atmosphereCtx); } }
/** * {@inheritDoc} */ public Action service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { CometContext ctx = CometEngine.getEngine().getCometContext(atmosphereCtx); Action action = suspended(req, res); if (action.type == Action.TYPE.SUSPEND) { if (logger.isLoggable(Level.FINE)){ logger.fine("Suspending" + res); } suspend(ctx, action, req, res); } else if (action.type == Action.TYPE.RESUME){ if (logger.isLoggable(Level.FINE)){ logger.fine("Resuming" + res); } resume(req,ctx); Action nextAction = resumed(req, res); if (nextAction.type == Action.TYPE.SUSPEND) { if (logger.isLoggable(Level.FINE)){ logger.fine("Suspending after Resuming" + res); } suspend(ctx, action, req, res); } } return action; }
/** * Create a Grizzly Comet {@link CometContext} * @param topic The name of the {@link CometContext} * @return a cached or newly created {@link CometContext} */ protected final CometContext createCometContext(String topic){ CometContext context = CometEngine.getEngine().register(topic); if (notificationHandler != null){ context.setNotificationHandler(notificationHandler); } context.setExpirationDelay(expirationDelay); context.setBlockingNotification(true); return context; }
CometContext context = CometEngine.getEngine().getCometContext(topic); if (context == null) { context = createCometContext(topic);
CometContext context = CometEngine.getEngine().getCometContext(topic); if (context == null && suspendOnTheFly) { context = createCometContext(topic);