@OnWebSocketError public void onWebSocketError(Throwable cause) { try { this.webSocketHandler.handleTransportError(this.wsSession, cause); } catch (Throwable t) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, t, logger); } }
@OnWebSocketMessage public void onWebSocketBinary(byte[] payload, int offset, int length) { BinaryMessage message = new BinaryMessage(payload, offset, length, true); try { this.webSocketHandler.handleMessage(this.wsSession, message); } catch (Throwable t) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, t, logger); } }
@OnWebSocketMessage public void onWebSocketText(String payload) { TextMessage message = new TextMessage(payload); try { this.webSocketHandler.handleMessage(this.wsSession, message); } catch (Throwable t) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, t, logger); } }
@OnWebSocketConnect public void onWebSocketConnect(Session session) { try { this.wsSession.initializeNativeSession(session); this.webSocketHandler.afterConnectionEstablished(this.wsSession); } catch (Throwable t) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, t, logger); } }
@OnWebSocketFrame public void onWebSocketFrame(Frame frame) { if (OpCode.PONG == frame.getOpCode()) { ByteBuffer payload = frame.getPayload() != null ? frame.getPayload() : EMPTY_PAYLOAD; PongMessage message = new PongMessage(payload); try { this.webSocketHandler.handleMessage(this.wsSession, message); } catch (Throwable t) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, t, logger); } } }