Example usage for org.springframework.web.socket WebSocketSession close

List of usage examples for org.springframework.web.socket WebSocketSession close

Introduction

In this page you can find the example usage for org.springframework.web.socket WebSocketSession close.

Prototype

void close(CloseStatus status) throws IOException;

Source Link

Document

Close the WebSocket connection with the given close status.

Usage

From source file:com.jxt.web.websocket.OrderedWebSocketFlushRunnable.java

private void closeSession(WebSocketSession session) {
    try {//from  ww w .j a v a  2  s .co  m
        session.close(CloseStatus.SERVER_ERROR);
    } catch (Exception e) {
        LOGGER.warn(e.getMessage(), e);
    }
}

From source file:com.pubkit.platform.messaging.PKMPConnectionHandler.java

@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
    session.close(CloseStatus.SERVER_ERROR);
}

From source file:com.omni.fansoffury.TestEchoWebSocketHandler.java

@Override
public void handleTransportError(WebSocketSession session, Throwable e) throws Exception {
    logger.error("Socket threw error", e);
    session.close(CloseStatus.SERVER_ERROR);
}

From source file:ymanv.forex.websocket.RatesWebSocketHandler.java

@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws IOException {
    session.close(CloseStatus.SERVER_ERROR);
}

From source file:com.csavory.websocket.client.StringWebSocketHandler.java

@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
    logger.error("Transport Error", exception);
    session.close(CloseStatus.SERVER_ERROR);
}

From source file:com.devicehive.websockets.util.SessionMonitor.java

@PreDestroy
public void closeAllSessions() {
    for (WebSocketSession session : sessionMap.values()) {
        try {/*from   www.  j av  a2 s.  c om*/
            session.close(CloseStatus.SERVICE_RESTARTED);
        } catch (IOException ex) {
            logger.error("Error closing session", ex);
        }
    }
    sessionMap.clear();
}

From source file:com.kjipo.echo.EchoWebSocketHandler.java

@Override
public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception {
    logger.debug("Closing session: {}", session);
    session.close(CloseStatus.SERVER_ERROR);
    simpleWebSocketMessageSender.removeMessageConsumer(sessionIdMessageConsumerMap.get(session.getId()));
}

From source file:ch.rasc.wampspring.session.WebSocketRegistryListener.java

private void closeWsSessions(String httpSessionId) {
    Map<String, WebSocketSession> sessionsToClose = this.httpSessionIdToWsSessions.remove(httpSessionId);
    if (sessionsToClose == null) {
        return;//from   w  w  w .  j ava2 s. com
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Closing WebSocket connections associated to expired HTTP Session " + httpSessionId);
    }
    for (WebSocketSession toClose : sessionsToClose.values()) {
        try {
            toClose.close(SESSION_EXPIRED_STATUS);
        } catch (IOException e) {
            logger.debug(
                    "Failed to close WebSocketSession (this is nothing to worry about but for debugging only)",
                    e);
        }
    }
}

From source file:samples.websocket.behavoir.CloseWithCodeWebSocketHandler.java

@Override
public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
    Integer code;//from  w  w  w.  j  ava  2 s .  c  o  m
    try {
        code = Integer.parseInt(message.getPayload());
        session.close(new CloseStatus(code));
    } catch (NumberFormatException e) {
        session.sendMessage(new TextMessage("unable to parse close code"));
    }
}

From source file:com.pubkit.platform.messaging.protocol.pkmp.PKMPOutBoundEventHandler.java

private void closeSession(WebSocketSession session) {
    if (!session.isOpen()) {
        return;/*from   w w w .jav  a 2s  . c om*/
    }
    try {
        session.close(CloseStatus.NORMAL);
    } catch (IOException e) {
        LOG.error("Error closing the connection", e);
        // Can't do anything now!
    }
}