protected void executeAsyncWrite( final AtmosphereResource<?, ?> resource, final Object msg, final BroadcasterFuture future) { if (resource.getAtmosphereResourceEvent().isCancelled()) { return; } final AtmosphereResourceEvent event = resource.getAtmosphereResourceEvent(); event.setMessage(msg); try { if (resource.getAtmosphereResourceEvent() != null && !resource.getAtmosphereResourceEvent().isCancelled() && HttpServletRequest.class.isAssignableFrom(resource.getRequest().getClass())) { HttpServletRequest.class .cast(resource.getRequest()) .setAttribute(CometSupport.MAX_INACTIVE, System.currentTimeMillis()); } } catch (Exception t) { // Shield us from any corrupted Request logger.debug("Preventing corruption of a recycled request: resource" + resource, event); removeAtmosphereResource(resource); BroadcasterFactory.getDefault().removeAllAtmosphereResource(resource); return; } broadcast(resource, event); if (resource instanceof AtmosphereEventLifecycle) { ((AtmosphereEventLifecycle) resource).notifyListeners(); } if (future != null) { future.done(); } }
protected boolean retrieveTrackedBroadcast( final AtmosphereResource<?, ?> r, final AtmosphereResourceEvent e) { List<?> missedMsg = broadcasterCache.retrieveFromCache(r); if (!missedMsg.isEmpty()) { e.setMessage(missedMsg); return true; } return false; }