@Override protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) { try { session.close(CloseStatus.NOT_ACCEPTABLE.withReason("Binary messages not supported")); } catch (IOException ex) { // ignore } }
/** * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header. * @param secWebSocketProtocol the value of the header */ public void setSecWebSocketProtocol(String secWebSocketProtocol) { set(SEC_WEBSOCKET_PROTOCOL, secWebSocketProtocol); }
@Override protected void closeConnection() throws Exception { if (this.webSocketSession != null) { this.webSocketSession.close(); } }
@Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { session.sendMessage(new TextMessage("go go")); } };
private void handleTextMessage(javax.websocket.Session session, String payload, boolean isLast) { TextMessage textMessage = new TextMessage(payload, isLast); try { this.handler.handleMessage(this.wsSession, textMessage); } catch (Throwable ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } }
@Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { session.sendMessage(message); } }
private void handleBinaryMessage(javax.websocket.Session session, ByteBuffer payload, boolean isLast) { BinaryMessage binaryMessage = new BinaryMessage(payload, isLast); try { this.handler.handleMessage(this.wsSession, binaryMessage); } catch (Throwable ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } }
@Override public Principal getPrincipal() { return this.delegate.getPrincipal(); }
private void handlePongMessage(javax.websocket.Session session, ByteBuffer payload) { PongMessage pongMessage = new PongMessage(payload); try { this.handler.handleMessage(this.wsSession, pongMessage); } catch (Throwable ex) { ExceptionWebSocketHandlerDecorator.tryCloseWithError(this.wsSession, ex, logger); } }
@Override public String getAcceptedProtocol() { return this.delegate.getAcceptedProtocol(); }
/** * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header. * @param secWebSocketProtocols the value of the header */ public void setSecWebSocketProtocol(List<String> secWebSocketProtocols) { set(SEC_WEBSOCKET_PROTOCOL, toCommaDelimitedString(secWebSocketProtocols)); }
/** * Returns {@code WebSocketHttpHeaders} object that can only be read, not written to. */ public static WebSocketHttpHeaders readOnlyWebSocketHttpHeaders(WebSocketHttpHeaders headers) { return new WebSocketHttpHeaders(headers, true); }
/** * Set the sub-protocols to use. If configured, specified sub-protocols will be * requested in the handshake through the {@code Sec-WebSocket-Protocol} header. The * resulting WebSocket session will contain the protocol accepted by the server, if * any. */ public void setSubProtocols(List<String> protocols) { this.headers.setSecWebSocketProtocol(protocols); }
@Override public String toString() { return "SessionDisconnectEvent[sessionId=" + this.sessionId + ", " + this.status.toString() + "]"; }
/** * Return the configured sub-protocols to use. */ public List<String> getSubProtocols() { return this.headers.getSecWebSocketProtocol(); }
@Override public List<WebSocketExtension> getExtensions() { return this.delegate.getExtensions(); }
@Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { for (TextMessage message : this.messagesToSend) { session.sendMessage(message); } }
@Override protected void handleTextMessage(WebSocketSession session, TextMessage message) { try { session.close(CloseStatus.NOT_ACCEPTABLE.withReason("Text messages not supported")); } catch (IOException ex) { // ignore } }
@Override protected void disconnect(CloseStatus status) throws IOException { if (this.webSocketSession != null) { this.webSocketSession.close(status); } }