Package org.simpleframework.http.socket
Enum FrameType
- All Implemented Interfaces:
Serializable
,Comparable<FrameType>
,java.lang.constant.Constable
The
FrameType
represents the set of opcodes defined
in RFC 6455. The base framing protocol uses a opcode to define the
interpretation of the payload data for the frame.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA binary frame identifies a message that contains binary data.A close frame identifies a frame used to terminate a connection.A continuation frame identifies a fragment from a larger message.A ping frame is a heartbeat used to determine connection health.A pong frame is sent is sent in response to a ping frame.A text frame identifies a message that contains UTF-8 text data. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
FrameType
(int code) Constructor for theFrame
type enumeration. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isClose()
This is used to determine if a frame is a close frame.boolean
isPing()
This is used to determine if a frame is a ping frame.boolean
isPong()
This is used to determine if a frame is a pong frame.boolean
isText()
This is used to determine if a frame is a text frame.static FrameType
resolveType
(int octet) This is used to acquire the frame type given an opcode.static FrameType
Returns the enum constant of this type with the specified name.static FrameType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
CONTINUATION
A continuation frame identifies a fragment from a larger message. -
TEXT
A text frame identifies a message that contains UTF-8 text data. -
BINARY
A binary frame identifies a message that contains binary data. -
CLOSE
A close frame identifies a frame used to terminate a connection. -
PING
A ping frame is a heartbeat used to determine connection health. -
PONG
A pong frame is sent is sent in response to a ping frame.
-
-
Field Details
-
code
public final int codeThis is the integer value for the opcode.
-
-
Constructor Details
-
FrameType
private FrameType(int code) Constructor for theFrame
type enumeration. This is given the opcode that is used to identify a specific frame type.- Parameters:
code
- this is the opcode representing the frame type
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isText
public boolean isText()This is used to determine if a frame is a text frame. It can be useful to know if a frame is a user based frame as it reduces the need to convert from or to certain character sets.- Returns:
- this returns true if the frame represents a text frame
-
isClose
public boolean isClose()This is used to determine if a frame is a close frame. A close frame contains an optional payload, which if present contains an error code in network byte order in the first two bytes, followed by an optional UTF-8 text reason of the closure.- Returns:
- this returns true if the frame represents a close frame
-
isPong
public boolean isPong()This is used to determine if a frame is a pong frame. A pong frame is sent in response to a ping and is used to determine if a WebSocket connection is still active and healthy.- Returns:
- this returns true if the frame represents a pong frame
-
isPing
public boolean isPing()This is used to determine if a frame is a ping frame. A ping frame is sent to check if a WebSocket connection is still healthy. A connection is determined healthy if it responds with a pong frame is a reasonable length of time.- Returns:
- this returns true if the frame represents a ping frame
-
resolveType
This is used to acquire the frame type given an opcode. If no frame type can be determined from the opcode provided then this will return a null value.- Parameters:
octet
- this is the octet representing the opcode- Returns:
- this returns the frame type from the opcode
-