Class CloseStatus


  • public class CloseStatus
    extends java.lang.Object
    Representation of a WebSocket Close (status code & reason)
    • Constructor Detail

      • CloseStatus

        public CloseStatus()
        Creates a reason for closing a web socket connection with the no given status code.
      • CloseStatus

        public CloseStatus​(int statusCode)
        Creates a reason for closing a web socket connection with the given status code and no reason phrase.
        Parameters:
        statusCode - the close code
      • CloseStatus

        public CloseStatus​(int statusCode,
                           java.lang.String reasonPhrase)
        Creates a reason for closing a web socket connection with the given status code and reason phrase.
        Parameters:
        statusCode - the close code
        reasonPhrase - the reason phrase
      • CloseStatus

        public CloseStatus​(int statusCode,
                           java.lang.Throwable cause)
        Creates a reason for closing a web socket connection with the given status code and reason phrase.
        Parameters:
        statusCode - the close code
        cause - the error which caused the close
      • CloseStatus

        public CloseStatus​(int statusCode,
                           java.lang.String reasonPhrase,
                           java.lang.Throwable cause)
        Creates a reason for closing a web socket connection with the given status code and reason phrase.
        Parameters:
        statusCode - the close code
        reasonPhrase - the reason phrase
        cause - the error which caused the close
      • CloseStatus

        public CloseStatus​(Frame frame)
      • CloseStatus

        public CloseStatus​(java.nio.ByteBuffer payload)
    • Method Detail

      • isOrdinary

        public static boolean isOrdinary​(int closeCode)
      • isAbnormal

        public boolean isAbnormal()
      • getCause

        public java.lang.Throwable getCause()
      • getCode

        public int getCode()
      • getReason

        public java.lang.String getReason()
      • asPayloadBuffer

        public java.nio.ByteBuffer asPayloadBuffer()
      • asPayloadBuffer

        public static java.nio.ByteBuffer asPayloadBuffer​(int statusCode,
                                                          java.lang.String reason)
      • isTransmittableStatusCode

        public static boolean isTransmittableStatusCode​(int statusCode)
        Test if provided status code can be sent/received on a WebSocket close.

        This honors the RFC6455 rules and IANA rules.

        Parameters:
        statusCode - the statusCode to test
        Returns:
        true if transmittable
      • toFrame

        public Frame toFrame()
      • toFrame

        public static Frame toFrame​(int closeStatus)
      • toFrame

        public static Frame toFrame​(int closeStatus,
                                    java.lang.String reason)
      • codeString

        public static java.lang.String codeString​(int closeStatus)
      • isNormal

        public boolean isNormal()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object