Example usage for org.springframework.web.socket CloseStatus NO_STATUS_CODE

List of usage examples for org.springframework.web.socket CloseStatus NO_STATUS_CODE

Introduction

In this page you can find the example usage for org.springframework.web.socket CloseStatus NO_STATUS_CODE.

Prototype

CloseStatus NO_STATUS_CODE

To view the source code for org.springframework.web.socket CloseStatus NO_STATUS_CODE.

Click Source Link

Document

"1005 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.

Usage

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");
    }//from ww w . j ava2 s.com
    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:org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession.java

private void handleCloseFrame(SockJsFrame frame) {
    CloseStatus closeStatus = CloseStatus.NO_STATUS_CODE;
    try {/*w w  w. java2 s .c o m*/
        String frameData = frame.getFrameData();
        if (frameData != null) {
            String[] data = getMessageCodec().decode(frameData);
            if (data != null && data.length == 2) {
                closeStatus = new CloseStatus(Integer.valueOf(data[0]), data[1]);
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Processing SockJS close frame with " + closeStatus + " in " + this);
            }
        }
    } catch (IOException ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Failed to decode data for " + frame + " in " + this, ex);
        }
    }
    silentClose(closeStatus);
}