org.simpleframework.http.socket
Enum FrameType

java.lang.Object
  extended by java.lang.Enum<FrameType>
      extended by org.simpleframework.http.socket.FrameType
All Implemented Interfaces:
Serializable, Comparable<FrameType>

public enum FrameType
extends Enum<FrameType>

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.

Author:
Niall Gallagher
See Also:
Frame

Enum Constant Summary
BINARY
          A binary frame identifies a message that contains binary data.
CLOSE
          A close frame identifies a frame used to terminate a connection.
CONTINUATION
          A continuation frame identifies a fragment from a larger message.
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.
TEXT
          A text frame identifies a message that contains UTF-8 text data.
 
Field Summary
 int code
          This is the integer value for the opcode.
 
Method Summary
 boolean 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 valueOf(String name)
          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.
 
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

CONTINUATION

public static final FrameType CONTINUATION
A continuation frame identifies a fragment from a larger message.


TEXT

public static final FrameType TEXT
A text frame identifies a message that contains UTF-8 text data.


BINARY

public static final FrameType BINARY
A binary frame identifies a message that contains binary data.


CLOSE

public static final FrameType CLOSE
A close frame identifies a frame used to terminate a connection.


PING

public static final FrameType PING
A ping frame is a heartbeat used to determine connection health.


PONG

public static final FrameType PONG
A pong frame is sent is sent in response to a ping frame.

Field Detail

code

public final int code
This is the integer value for the opcode.

Method Detail

values

public static FrameType[] 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 (FrameType c : FrameType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static FrameType valueOf(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:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - 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

public static FrameType resolveType(int octet)
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


Copyright © 2014. All Rights Reserved.