public void initWebSocket() { if (webSocketProtocolInitialized) return; if (webSocketProtocol == null) { try { webSocketProtocol = newClassInstance(WebSocketProtocol.class, (Class<WebSocketProtocol>) IOUtils.loadClass(this.getClass(), webSocketProtocolClassName)); logger.info("Installed WebSocketProtocol {} ", webSocketProtocolClassName); } catch (Exception ex) { logger.error("Cannot load the WebSocketProtocol {}", getWebSocketProtocolClassName(), ex); try { webSocketProtocol = newClassInstance(WebSocketProtocol.class, SimpleHttpProtocol.class); } catch (Exception e) { } } } webSocketProtocolInitialized = true; webSocketProtocol.configure(config); }
List<AtmosphereRequest> list = webSocketProtocol.onMessage(webSocket, data, offset, length); dispatch(webSocket, list); } else {
/** * Dispatch to request/response to the {@link org.atmosphere.runtime.AsyncSupport} implementation as it was a normal HTTP request. * * @param request a {@link AtmosphereRequest} * @param r a {@link AtmosphereResponse} */ public final void dispatch(WebSocket webSocket, final AtmosphereRequest request, final AtmosphereResponse r) { if (request == null) return; try { framework.doCometSupport(request, r); } catch (Throwable e) { logger.warn("Failed invoking AtmosphereFramework.doCometSupport()", e); webSocketProtocol.onError(webSocket, new WebSocketException(e, new AtmosphereResponseImpl.Builder() .request(request) .status(500) .statusMessage("Server Error").build())); return; } if (r.getStatus() >= 400) { webSocketProtocol.onError(webSocket, new WebSocketException("Status code higher or equal than 400", r)); } }
boolean completeLifecycle = true; try { webSocketProtocol.onClose(webSocket);
webSocketProtocol.onOpen(webSocket); WebSocketHandler proxy = null; if (!handlers.isEmpty()) {
List<AtmosphereRequest> list = webSocketProtocol.onMessage(webSocket, webSocketMessage); dispatch(webSocket, list); } else {