List of usage examples for org.springframework.web.socket CloseStatus NORMAL
CloseStatus NORMAL
To view the source code for org.springframework.web.socket CloseStatus NORMAL.
Click Source Link
From source file:com.company.project.config.StompDisconnectEvent.java
@Override public void onApplicationEvent(SessionDisconnectEvent event) { StompHeaderAccessor sha = StompHeaderAccessor.wrap(event.getMessage()); CloseStatus status = event.getCloseStatus(); if (status.equals(CloseStatus.BAD_DATA)) { System.out.println("CloseStatus.BAD_DATA"); }/* w w w . j a v a 2 s.co m*/ if (status.equals(CloseStatus.GOING_AWAY)) { System.out.println("CloseStatus.GOING_AWAY"); } if (status.equals(CloseStatus.NORMAL)) { System.out.println("CloseStatus.NORMAL"); } if (status.equals(CloseStatus.NOT_ACCEPTABLE)) { System.out.println("CloseStatus.NOT_ACCEPTABLE"); } if (status.equals(CloseStatus.NO_CLOSE_FRAME)) { System.out.println("CloseStatus.NO_CLOSE_FRAME"); } if (status.equals(CloseStatus.NO_STATUS_CODE)) { System.out.println("CloseStatus.NO_STATUS_CODE"); } if (status.equals(CloseStatus.POLICY_VIOLATION)) { System.out.println("CloseStatus.POLICY_VIOLATION"); } if (status.equals(CloseStatus.PROTOCOL_ERROR)) { System.out.println("CloseStatus.PROTOCOL_ERROR"); } if (status.equals(CloseStatus.REQUIRED_EXTENSION)) { System.out.println("CloseStatus.REQUIRED_EXTENSION"); } if (status.equals(CloseStatus.SERVER_ERROR)) { System.out.println("CloseStatus.SERVER_ERROR"); } if (status.equals(CloseStatus.SERVICE_RESTARTED)) { System.out.println("CloseStatus.SERVICE_RESTARTED"); } if (status.equals(CloseStatus.SESSION_NOT_RELIABLE)) { System.out.println("CloseStatus.SESSION_NOT_RELIABLE"); } if (status.equals(CloseStatus.TLS_HANDSHAKE_FAILURE)) { System.out.println("CloseStatus.TLS_HANDSHAKE_FAILURE"); } if (status.equals(CloseStatus.TOO_BIG_TO_PROCESS)) { System.out.println("CloseStatus.TOO_BIG_TO_PROCESS"); } System.out.println("CloseStatus: " + status); logger.debug("Disconnect event [sessionId: " + sha.getSessionId() + " ]"); System.out.println("Disconnect event [sessionId: " + event.getSessionId() + " ]"); }
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 {/* w ww .j a va 2s . co m*/ log.info("Normal termination"); } protocolManager.closeSessionIfTimeout(wsSession.getId(), status.getReason()); }
From source file:com.pubkit.platform.messaging.protocol.pkmp.PKMPOutBoundEventHandler.java
private void closeSession(WebSocketSession session) { if (!session.isOpen()) { return;// ww w . j a va 2s . c o m } try { session.close(CloseStatus.NORMAL); } catch (IOException e) { LOG.error("Error closing the connection", e); // Can't do anything now! } }
From source file:org.kurento.jsonrpc.internal.ws.WebSocketServerSession.java
@Override public void closeNativeSession(String reason) { try {/*from ww w .j a v a 2 s .com*/ wsSession.close(new CloseStatus(CloseStatus.NORMAL.getCode(), reason)); } catch (IOException e) { log.warn("Exception closing webSocket session", e); } }
From source file:com.github.mrstampy.gameboot.otp.websocket.OtpEncryptedWebSocketHandler.java
/** * Process for binary./* w ww . j a v a 2 s . c o m*/ * * @param session * the session * @param msg * the msg * @throws Exception * the exception */ protected void processForBinary(WebSocketSession session, byte[] msg) throws Exception { OtpKeyRequest message = converter.fromJson(msg); if (!validateChannel(session, message)) return; Response r = processor.process(message); if (r == null || !r.isSuccess()) { log.error("Unexpected response {}, disconnecting {}", r, session); session.close(); return; } BinaryMessage bm = new BinaryMessage(converter.toJsonArray(r)); session.sendMessage(bm); log.debug("Successful send of {} to {}", message.getType(), session.getRemoteAddress()); Thread.sleep(50); session.close(CloseStatus.NORMAL); }
From source file:smpp.networking.SimpleStompClient.java
public void close() throws Exception { session.close(CloseStatus.NORMAL.getCode(), "SimpleStompClient.close() called"); client.stop(); }
From source file:com.zb.app.websocket.server.WebSocketServerHandler.java
/** * ?mId,Session,client// w w w. ja v a 2 s. c o m * * @param mId */ public void removeSession(Long mId) { Set<SessionWrapper> set = getSessionInfo(mId); if (Argument.isEmpty(set)) { return; } for (SessionWrapper sessionWrapper : set) { ClientWrapper clientInfo = sessionWrapper.getClientInfo(); String sessionId = sessionWrapper.getId(); String ip = clientInfo.getIp(); try { sessionWrapper.getSocketSession().close(CloseStatus.NORMAL); logger.error("WebSocketServerHandler removeSession() successfull! mid={},sessionId={},ip={}", mId, sessionId, ip); } catch (Exception e) { logger.error("WebSocketServerHandler removeSession() faild! mid={},sessionId={},ip={}", mId, sessionId, ip); } finally { sessionCacheMap.remove(clientInfo); } } }
From source file:com.zb.app.websocket.server.WebSocketServerHandler.java
/** * ?WebSocketSession,Session//from w w w .j a v a 2 s . c o m * * @param session Session */ public void removeSession(WebSocketSession session) { SessionWrapper sw = getSessionInfo(session); if (sw == null || StringUtils.isEmpty(sw.getId())) { return; } ClientWrapper clientInfo = sw.getClientInfo(); String sessionId = sw.getId(); String ip = clientInfo.getIp(); Long mId = clientInfo.getmId(); try { session.close(CloseStatus.NORMAL); logger.error("WebSocketServerHandler removeSession() successfull! mid={},sessionId={},ip={}", mId, sessionId, ip); } catch (Exception e) { if (session != null && !session.isOpen()) { logger.error( "WebSocketServerHandler removeSession() is Normally closed! mid={},sessionId={},ip={}", mId, sessionId, ip); } else { logger.error("WebSocketServerHandler removeSession() faild! mid={},sessionId={},ip={}", mId, sessionId, ip); } } finally { Set<SessionWrapper> set = sessionCacheMap.get(clientInfo); set.remove(sw); if (Argument.isEmpty(set)) { sessionCacheMap.remove(clientInfo); } } }
From source file:org.springframework.web.socket.adapter.AbstractWebSocketSession.java
@Override public final void close() throws IOException { close(CloseStatus.NORMAL); }
From source file:org.springframework.web.socket.adapter.AbstractWebSocketSesssionAdapter.java
@Override public void close() throws IOException { close(CloseStatus.NORMAL); }