List of usage examples for org.springframework.web.socket CloseStatus getReason
@Nullable
public String getReason()
From source file:com.github.sshw.websocket.SSHWebSocketHandler.java
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { log.info("websocket connection closed: {}", status.getReason()); SSHSession sshSession = sshSessionManager.sessionsByWebsocketID.get(session.getId()); if (sshSession != null) { sshSession.logout();/*from ww w . j a va 2 s .c om*/ } sshSessionManager.sessionsByWebsocketID.remove(session.getId()); }
From source file:com.hxh.websocket.handler.AndroidEndPoint.java
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { System.out.println("" + getClientAddress(session) + "websocket?:" + status.getCode() + "" + status.getReason()); super.afterConnectionClosed(session, status); }
From source file:io.sevenluck.chat.websocket.ChatWebSocketHandler.java
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { final String token = (String) session.getAttributes().get(HttpAuthTokenHandShakeInterceptor.X_TOKEN); logger.info("afterConnectionClosed with token {} and cause {}", token, status.getReason()); if (sessionMap.containsKey(token)) { sessionMap.remove(token);//from ww w . jav a 2s .co m } else { logger.info("could not find any websession for token {}", token); } }
From source file:org.kurento.jsonrpc.internal.ws.JsonRpcWebSocketHandler.java
@Override public void afterConnectionClosed(WebSocketSession wsSession, org.springframework.web.socket.CloseStatus status) throws Exception { log.info("{} WebSocket session '{}' closed for {} (code {}, reason '{}')", label, wsSession.getId(), CloseStatusHelper.getCloseStatusType(status.getCode()), status.getCode(), status.getReason()); protocolManager.closeSessionIfTimeout(wsSession.getId(), status.getReason()); }
From source file:com.kurento.kmf.jsonrpcconnector.internal.ws.JsonRpcWebSocketHandler.java
@Override public void afterConnectionClosed(WebSocketSession wsSession, org.springframework.web.socket.CloseStatus status) throws Exception { log.info("Connection closed because: " + status); if (!status.equals(CloseStatus.NORMAL)) { log.error("Abnormal termination"); } else {//www . j ava 2 s.c o m log.info("Normal termination"); } protocolManager.closeSessionIfTimeout(wsSession.getId(), status.getReason()); }
From source file:com.kurento.kmf.jsonrpcconnector.client.JsonRpcClientWebSocket.java
private synchronized void connectIfNecessary() throws IOException { if (wsSession == null) { final CountDownLatch latch = new CountDownLatch(1); TextWebSocketHandler webSocketHandler = new TextWebSocketHandler() { @Override//from www . j a v a 2s.c o m public void afterConnectionEstablished(WebSocketSession wsSession2) throws Exception { wsSession = wsSession2; rs = new WebSocketResponseSender(wsSession); latch.countDown(); } @Override public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { handleWebSocketTextMessage(message); } @Override public void afterConnectionClosed(WebSocketSession s, CloseStatus status) throws Exception { // TODO Call this when you can't reconnect or close is // issued by client. handlerManager.afterConnectionClosed(session, status.getReason()); log.debug("WebSocket closed due to: {}", status); wsSession = null; // TODO Start a timer to force reconnect in x millis // For the moment we are going to force it sending another // message. } }; WebSocketConnectionManager connectionManager = new WebSocketConnectionManager( new StandardWebSocketClient(), webSocketHandler, url); connectionManager.setHeaders(headers); connectionManager.start(); try { latch.await(); if (session == null) { session = new ClientSession(null, null, JsonRpcClientWebSocket.this); handlerManager.afterConnectionEstablished(session); } else { String result = rsHelper.sendRequest(JsonRpcConstants.METHOD_RECONNECT, String.class); log.info("Reconnection result: {}", result); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
From source file:org.springframework.web.socket.sockjs.AbstractSockJsSession.java
/** * {@inheritDoc}/* w ww . j a v a 2 s .c o m*/ * <p>Performs cleanup and notifies the {@link SockJsHandler}. */ @Override public final void close(CloseStatus status) throws IOException { if (isOpen()) { if (logger.isDebugEnabled()) { logger.debug("Closing " + this + ", " + status); } try { if (isActive()) { // TODO: deliver messages "in flight" before sending close frame try { // bypass writeFrame writeFrameInternal(SockJsFrame.closeFrame(status.getCode(), status.getReason())); } catch (Throwable ex) { logger.warn("Failed to send SockJS close frame: " + ex.getMessage()); } } updateLastActiveTime(); cancelHeartbeat(); disconnect(status); } finally { this.state = State.CLOSED; try { this.handler.afterConnectionClosed(this, status); } catch (Throwable t) { logger.error("Unhandled error for " + this, t); } } } }
From source file:org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.java
/** * Performs cleanup and notify the {@link WebSocketHandler}. *//*from w ww . ja va 2 s . co m*/ @Override public final void close(CloseStatus status) throws IOException { if (isOpen()) { if (logger.isDebugEnabled()) { logger.debug("Closing SockJS session " + getId() + " with " + status); } this.state = State.CLOSED; try { if (isActive() && !CloseStatus.SESSION_NOT_RELIABLE.equals(status)) { try { writeFrameInternal(SockJsFrame.closeFrame(status.getCode(), status.getReason())); } catch (Throwable ex) { logger.debug("Failure while sending SockJS close frame", ex); } } updateLastActiveTime(); cancelHeartbeat(); disconnect(status); } finally { try { this.handler.afterConnectionClosed(this, status); } catch (Throwable ex) { logger.debug("Error from WebSocketHandler.afterConnectionClosed in " + this, ex); } } } }