Example usage for org.springframework.web.socket.sockjs.frame SockJsFrame closeFrame

List of usage examples for org.springframework.web.socket.sockjs.frame SockJsFrame closeFrame

Introduction

In this page you can find the example usage for org.springframework.web.socket.sockjs.frame SockJsFrame closeFrame.

Prototype

public static SockJsFrame closeFrame(int code, @Nullable String reason) 

Source Link

Usage

From source file:org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.java

/**
 * Performs cleanup and notify the {@link WebSocketHandler}.
 *///from w  ww. j a  v  a 2 s.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);
            }
        }
    }
}