@Override public void onOpen(WebSocket.Connection connection) { try { webSocketProcessor = (WebSocketProcessor) JettyWebSocketHandler.class .getClassLoader() .loadClass(webSocketProcessorClassName) .getDeclaredConstructor( new Class[] {AtmosphereServlet.class, WebSocketSupport.class}) .newInstance( new Object[] {atmosphereServlet, new Jetty8WebSocketSupport(connection)}); webSocketProcessor.connect(new JettyRequestFix(request)); } catch (Exception e) { logger.warn("failed to connect to web socket", e); } }
@Override public boolean onControl(byte controlCode, byte[] data, int offset, int length) { webSocketProcessor.broadcast(data, offset, length); return false; }
@Override public void onMessage(byte[] data, int offset, int length) { webSocketProcessor.broadcast(data, offset, length); }
@Override public void onDisconnect() { webSocketProcessor.close(); }
@Override public void onFragment(boolean more, byte opcode, byte[] data, int offset, int length) { webSocketProcessor.broadcast(new String(data, offset, length)); }
@Override public void onMessage(byte frame, byte[] data, int offset, int length) { webSocketProcessor.broadcast(new String(data, offset, length)); }
@Override public void onMessage(byte frame, String data) { webSocketProcessor.broadcast(data); }
@Override public void onClose(int closeCode, String message) { webSocketProcessor.close(); }
@Override public boolean onFrame(byte flags, byte opcode, byte[] data, int offset, int length) { webSocketProcessor.broadcast(data, offset, length); logger.debug("WebSocket.onFrame"); return false; }