Enum CloseCode

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CloseCode>

    public enum CloseCode
    extends java.lang.Enum<CloseCode>
    The CloseCode enumerates the closure codes specified in RFC 6455. When closing an established connection an endpoint may indicate a reason for closure. The interpretation of this reason by an endpoint, and the action an endpoint should take given this reason, are left undefined by RFC 6455. The specification defines a set of status codes and specifies which ranges may be used by extensions, frameworks, and end applications. The status code and any associated textual message are optional components of a Close frame.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ABNORMAL_CLOSURE
      Indicates an abnormal closure and should not be used.
      GOING_AWAY
      Indicates that the server is going down or the client browsed away.
      INTERNAL_SERVER_ERROR
      Indicates an unexpected error within the server.
      INVALID_FRAME_DATA
      Indicates that a payload was not consistent with the message type.
      NO_EXTENSION
      Indicates that the server did not negotiate an extension properly.
      NO_STATUS_CODE
      Indicates that no status code was present and should not be used.
      NORMAL_CLOSURE
      Indicates the purpose for the connection has been fulfilled.
      POLICY_VIOLATION
      Indicates an endpoint received a message that violates its policy.
      PROTOCOL_ERROR
      Indicates the connection is terminating due to a protocol error.
      RESERVED
      According to RFC 6455 this has been reserved for future use.
      TLS_HANDSHAKE_FAILURE
      Indicates a validation failure for TLS and should not be used.
      TOO_BIG
      Indicates that a payload is too big to be processed.
      UNSUPPORTED_DATA
      Indicates the connection received a data type it cannot accept.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int code
      This is the actual integer value representing the code.
      int high
      This is the high order byte for the closure code.
      int low
      This is the low order byte for the closure code.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CloseCode​(int code)
      Constructor for the CloseCode object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getData()
      This is the data that represents the closure code.
      static CloseCode resolveCode​(int high, int low)  
      static CloseCode valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CloseCode[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • NORMAL_CLOSURE

        public static final CloseCode NORMAL_CLOSURE
        Indicates the purpose for the connection has been fulfilled.
      • GOING_AWAY

        public static final CloseCode GOING_AWAY
        Indicates that the server is going down or the client browsed away.
      • PROTOCOL_ERROR

        public static final CloseCode PROTOCOL_ERROR
        Indicates the connection is terminating due to a protocol error.
      • UNSUPPORTED_DATA

        public static final CloseCode UNSUPPORTED_DATA
        Indicates the connection received a data type it cannot accept.
      • RESERVED

        public static final CloseCode RESERVED
        According to RFC 6455 this has been reserved for future use.
      • NO_STATUS_CODE

        public static final CloseCode NO_STATUS_CODE
        Indicates that no status code was present and should not be used.
      • ABNORMAL_CLOSURE

        public static final CloseCode ABNORMAL_CLOSURE
        Indicates an abnormal closure and should not be used.
      • INVALID_FRAME_DATA

        public static final CloseCode INVALID_FRAME_DATA
        Indicates that a payload was not consistent with the message type.
      • POLICY_VIOLATION

        public static final CloseCode POLICY_VIOLATION
        Indicates an endpoint received a message that violates its policy.
      • TOO_BIG

        public static final CloseCode TOO_BIG
        Indicates that a payload is too big to be processed.
      • NO_EXTENSION

        public static final CloseCode NO_EXTENSION
        Indicates that the server did not negotiate an extension properly.
      • INTERNAL_SERVER_ERROR

        public static final CloseCode INTERNAL_SERVER_ERROR
        Indicates an unexpected error within the server.
      • TLS_HANDSHAKE_FAILURE

        public static final CloseCode TLS_HANDSHAKE_FAILURE
        Indicates a validation failure for TLS and should not be used.
    • Field Detail

      • code

        public final int code
        This is the actual integer value representing the code.
      • high

        public final int high
        This is the high order byte for the closure code.
      • low

        public final int low
        This is the low order byte for the closure code.
    • Constructor Detail

      • CloseCode

        private CloseCode​(int code)
        Constructor for the CloseCode object. This is used to create a closure code using one of the pre-defined values within RFC 6455.
        Parameters:
        code - this is the code that is to be used
    • Method Detail

      • values

        public static CloseCode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CloseCode c : CloseCode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CloseCode valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getData

        public byte[] getData()
        This is the data that represents the closure code. The array contains the high order byte and the low order byte as taken from the pre-defined closure code.
        Returns:
        a byte array representing the closure code
      • resolveCode

        public static CloseCode resolveCode​(int high,
                                            int low)