List of usage examples for org.springframework.web.socket WebSocketSession close
@Override void close() throws IOException;
From source file:com.songjg.websocket.handler.SystemWebSocketHandler.java
@Override public void handleTransportError(WebSocketSession wss, Throwable thrwbl) throws Exception { if (wss.isOpen()) { wss.close(); }//from w w w .java2 s .co m System.out.println("websocket connection closed......"); }
From source file:com.acme.doktoric.handler.SimpleClientWebSocketHandler.java
@Override public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { logger.debug("Received: " + message); session.close(); }
From source file:com.gaodashang.demo.client.SimpleClientWebSocketHandler.java
@Override public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { this.logger.info("Received: " + message + " (" + this.latch.getCount() + ")"); session.close(); this.messagePayload.set(message.getPayload()); this.latch.countDown(); }
From source file:com.devicehive.websockets.util.SessionMonitor.java
public void removeSession(String sessionId) throws IOException { sessionMap.remove(sessionId);/* w w w . j a v a 2s . c o m*/ WebSocketSession session = sessionMap.get(sessionId); try { if (session != null) session.close(); } catch (IOException ex) { logger.error("Error closing session", ex); } }
From source file:org.opencron.server.websocket.TerminalHandler.java
@Override public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { super.handleTransportError(session, exception); this.closeTerminal(session); session.close(); }
From source file:com.uplink.mowitnow.websocket.MowItNowWebSocketHandler.java
@Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { logger.info("Get message :" + message.getPayload()); mowItNowContext = new WebSocketMowItNowContext(message.getPayload(), session); mowItNowContext.parse();//from ww w. ja v a 2 s . c o m mowItNowContext.move(); session.close(); }
From source file:cn.sinobest.websocket.handler.SimpleClientWebSocketHandler.java
/** * ?/*from www .ja v a2s. c o m*/ * * @param webSocketSession WebSocketSession * @throws Exception */ @Override public void afterConnectionEstablished(WebSocketSession webSocketSession) throws Exception { String userid = getAttributes(webSocketSession, "userid"); if (!UserSecurity.addUser(userid, webSocketSession)) { //? webSocketSession.close(); } else { //?????? logger.info("????-->" + userid); messageService.sendFullMessage(userid, webSocketSession); } }
From source file:com.github.mrstampy.gameboot.otp.websocket.OtpEncryptedWebSocketHandler.java
/** * Validates that the clear channel exists. Override to provide additional * validation./*www. j a v a 2 s.com*/ * * @param session * the session * @param message * the message * @return true, if successful * @throws Exception * the exception */ protected boolean validateChannel(WebSocketSession session, OtpKeyRequest message) throws Exception { if (message.getKeyFunction() == null) { log.error("No key function, closing channel"); session.close(); return false; } switch (message.getKeyFunction()) { case NEW: break; default: log.error("Cannot process {}, closing OTP New Key session {}", message, session); session.close(); return false; } Long systemId = message.getOtpSystemId(); if (systemId == null) { log.error("System id missing from {}, disconnecting {}", message, session); session.close(); return false; } SystemIdKey sik = new SystemIdKey(systemId); WebSocketSession clearChannel = registry.get(sik); if (clearChannel == null || !clearChannel.isOpen()) { log.error("No clear channel for {}, from encrypted channel {}, disconnecting", systemId, session.getRemoteAddress()); session.close(); return false; } return true; }
From source file:cn.com.inhand.devicenetworks.ap.websocket.WSDNAccessPoint.java
/** * websocket/*from w w w . ja va 2 s . com*/ * * @param session */ protected void close(WebSocketSession session) { try { session.close(); } catch (IOException ex) { Logger.getLogger(WSDNAccessPoint.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.opencron.server.websocket.TerminalHandler.java
@Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { super.handleTextMessage(session, message); try {/*from w w w . ja va 2 s . c om*/ getClient(session, null); if (this.terminalClient != null) { if (!terminalClient.isClosed()) { terminalClient.write(message.getPayload()); } else { session.close(); } } } catch (Exception e) { session.sendMessage(new TextMessage("Sorry! Opencron Terminal was closed, please try again. ")); terminalClient.disconnect(); session.close(); } }