List of usage examples for org.springframework.web.socket CloseStatus getCode
public int getCode()
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: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:cn.com.inhand.devicenetworks.ap.websocket.WSDNAccessPoint.java
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { System.out.println("Debug in WSDNAccessPoint.java [Ln:50] : WebSocketSession session=" + session.toString() + " is colsed. stauts=" + status); //----call ?api websocket WSDNSession wsdnsn = this.cinfo.getWsdnsn(session.toString()); if (wsdnsn != null) { wsdnsn.setSession(session);/*from www. j a v a2s .c o m*/ wsdnsn.setLast_msg(System.currentTimeMillis()); this.cinfo.getWssn_map().remove(wsdnsn.getId()); wsdnsn.setIsLogin(false); wsdnsn.setSession(null); /** * status.getCode() 1000 1001? * */ int status_code = status.getCode(); if (status_code == 1000) { if (wsdnsn.getAction() >= 3) { this.updateStatus(wsdnsn.getAction(), wsdnsn); } else { this.updateStatus(202, wsdnsn); } } else { if (wsdnsn.getAction() >= 3) { this.updateStatus(wsdnsn.getAction(), wsdnsn); } else { this.updateStatus(202, wsdnsn); } } } //mapsession this.cinfo.getWsdnsn_map().remove(session.toString()); super.afterConnectionClosed(session, status); }
From source file:org.springframework.web.socket.sockjs.AbstractSockJsSession.java
/** * {@inheritDoc}//from ww w . j a va 2s . c om * <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.client.AbstractClientSockJsSession.java
private boolean isUserSetStatus(@Nullable CloseStatus status) { return (status != null && (status.getCode() == 1000 || (status.getCode() >= 3000 && status.getCode() <= 4999))); }
From source file:org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.java
/** * Performs cleanup and notify the {@link WebSocketHandler}. *//*from w w w . j a va 2s . c o 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); } } } }