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

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

Introduction

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

Prototype

CloseStatus NOT_ACCEPTABLE

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

Click Source Link

Document

"1003 indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message)."

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");
    }/*  www.j a v  a2  s.c o 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.github.mrstampy.gameboot.otp.websocket.OtpClearWebSocketHandler.java

protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
    try {/*from w  w w .ja v a 2s .  c om*/
        session.close(CloseStatus.NOT_ACCEPTABLE.withReason("Text messages not supported"));
    } catch (IOException e) {
        // ignore
    }
}