Enum Class Opcode

java.lang.Object
java.lang.Enum<Opcode>
de.craftsblock.craftsnet.api.websocket.Opcode
All Implemented Interfaces:
Serializable, Comparable<Opcode>, Constable

public enum Opcode extends Enum<Opcode>
Enumeration representing WebSocket opcodes along with their integer values. These opcodes are defined in the WebSocket protocol.
Since:
3.0.5-SNAPSHOT
  • Enum Constant Details

    • CONTINUATION

      public static final Opcode CONTINUATION
      Indicates a continuation frame.
    • TEXT

      public static final Opcode TEXT
      Indicates a text frame.
    • BINARY

      public static final Opcode BINARY
      Indicates a binary frame.
    • PING

      public static final Opcode PING
      Indicates a Ping frame.
    • PONG

      public static final Opcode PONG
      Indicates a Pong frame.
    • CLOSE

      public static final Opcode CLOSE
      Indicates a Close frame.
    • UNKNOWN

      public static final Opcode UNKNOWN
      Indicates that an opcode is unknown.
  • Method Details

    • values

      public static Opcode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Opcode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • intValue

      public int intValue()
      Retrieves the integer value of the opcode.
      Returns:
      The integer value representing the opcode.
    • byteValue

      public byte byteValue()
      Retrieves the byte value of the opcode.
      Returns:
      The byte value representing the opcode.
    • isDataCode

      public boolean isDataCode()
      Checks if the opcode is a code which should contain data
      Returns:
      true if is a data code, false otherwise
    • isControlCode

      public boolean isControlCode()
      Checks if the opcode is a code which should contain control instruction
      Returns:
      true if is a control code, false otherwise
    • isUnknown

      public boolean isUnknown()
      Checks if the opcode is not a valid opcode as defined in RFC 6455
      Returns:
      true if the opcode is defined, false otherwise
    • fromInt

      public static Opcode fromInt(int controlByte)
      Retrieves the opcode corresponding to the given integer value.
      Parameters:
      controlByte - The integer value of the opcode.
      Returns:
      The ControlByte corresponding to the integer value, or null if not found.
    • fromByte

      public static Opcode fromByte(byte controlByte)
      Retrieves the opcode corresponding to the given byte value.
      Parameters:
      controlByte - The byte value of the opcode.
      Returns:
      The ControlByte corresponding to the byte value, or null if not found.