public synchronized void cancel() throws IOException { action.type(Action.TYPE.RESUME); if (isCancelled.getAndSet(true)) return; if (asyncSupport instanceof AsynchronousProcessor) { try { AsynchronousProcessor.class.cast(asyncSupport).resumed(req, response); } catch (ServletException e) { logger.trace("", e); } } asyncSupport.action(this); // We must close the underlying WebSocket as well. if (AtmosphereResponse.class.isAssignableFrom(response.getClass())) { AtmosphereResponse.class.cast(response).close(); AtmosphereResponse.class.cast(response).destroy(); } if (AtmosphereRequest.class.isAssignableFrom(req.getClass())) { AtmosphereRequest.class.cast(req).destroy(); } // TODO: Grab some measurement. // req = null; // response = null; // Just in case if (broadcaster != null) { broadcaster.removeAtmosphereResource(this); } event.destroy(); }
public void cancel() throws IOException { if (!isCancelled.getAndSet(true)) { logger.trace("Cancelling {}", uuid); if (config.getBroadcasterFactory().getDefault() != null) { config.getBroadcasterFactory().getDefault().removeAllAtmosphereResource(this); if (transport.equals(TRANSPORT.WEBSOCKET)) { String parentUUID = (String) req.getAttribute(SUSPENDED_ATMOSPHERE_RESOURCE_UUID); AtmosphereResource p = AtmosphereResourceFactory.getDefault().find(parentUUID); if (p != null) { config.getBroadcasterFactory().getDefault().removeAllAtmosphereResource(p); } } } asyncSupport.complete(this); SessionTimeoutSupport.restoreTimeout(req); action.type(Action.TYPE.CANCELLED); if (asyncSupport != null) asyncSupport.action(this); // We must close the underlying WebSocket as well. if (AtmosphereResponse.class.isAssignableFrom(response.getClass())) { AtmosphereResponse.class.cast(response).close(); AtmosphereResponse.class.cast(response).destroy(); } if (AtmosphereRequest.class.isAssignableFrom(req.getClass())) { AtmosphereRequest.class.cast(req).destroy(); } req.removeAttribute(FrameworkConfig.ATMOSPHERE_RESOURCE); event.destroy(); } }
public void cancel() throws IOException { if (!isCancelled.getAndSet(true)) { logger.trace("Cancelling {}", uuid); action.type(Action.TYPE.RESUME); asyncSupport.action(this); // We must close the underlying WebSocket as well. if (AtmosphereResponse.class.isAssignableFrom(response.getClass())) { AtmosphereResponse.class.cast(response).close(); AtmosphereResponse.class.cast(response).destroy(); } if (AtmosphereRequest.class.isAssignableFrom(req.getClass())) { AtmosphereRequest.class.cast(req).destroy(); } if (broadcaster != null) { broadcaster.removeAtmosphereResource(this); } event.destroy(); } }