Class WebSocketFrame
java.lang.Object
org.eclipse.jetty.websocket.common.WebSocketFrame
- All Implemented Interfaces:
Frame
- Direct Known Subclasses:
ControlFrame
,DataFrame
A Base Frame as seen in RFC 6455. Sec 5.2
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-------+-+-------------+-------------------------------+ |F|R|R|R| opcode|M| Payload len | Extended payload length | |I|S|S|S| (4) |A| (7) | (16/64) | |N|V|V|V| |S| | (if payload len==126/127) | | |1|2|3| |K| | | +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | Extended payload length continued, if payload len == 127 | + - - - - - - - - - - - - - - - +-------------------------------+ | |Masking-key, if MASK set to 1 | +-------------------------------+-------------------------------+ | Masking-key (continued) | Payload Data | +-------------------------------- - - - - - - - - - - - - - - - + : Payload Data continued ... : + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | Payload Data continued ... | +---------------------------------------------------------------+
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.jetty.websocket.api.extensions.Frame
Frame.Type
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteBuffer
The payload data.protected byte
Combined FIN + RSV1 + RSV2 + RSV3 + OpCode byte.protected byte[]
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
static WebSocketFrame
protected void
copyHeaders
(Frame frame) protected void
copyHeaders
(WebSocketFrame copy) boolean
byte[]
getMask()
final byte
Get the payload ByteBuffer.int
The original payload length (Buffer.remaining()
)getType()
int
hashCode()
boolean
abstract boolean
abstract boolean
boolean
isFin()
boolean
isLast()
Same asFrame.isFin()
boolean
isMasked()
boolean
isRsv1()
boolean
isRsv2()
boolean
isRsv3()
void
reset()
setFin
(boolean fin) setMask
(byte[] maskingKey) setMasked
(boolean mask) protected WebSocketFrame
setOpCode
(byte op) setPayload
(ByteBuffer buf) Set the data payload.setRsv1
(boolean rsv1) setRsv2
(boolean rsv2) setRsv3
(boolean rsv3) toString()
-
Field Details
-
finRsvOp
protected byte finRsvOpCombined FIN + RSV1 + RSV2 + RSV3 + OpCode byte.1000_0000 (0x80) = fin 0100_0000 (0x40) = rsv1 0010_0000 (0x20) = rsv2 0001_0000 (0x10) = rsv3 0000_1111 (0x0F) = opcode
-
masked
protected boolean masked -
mask
protected byte[] mask -
data
The payload data.It is assumed to always be in FLUSH mode (ready to read) in this object.
-
-
Constructor Details
-
WebSocketFrame
protected WebSocketFrame(byte opcode) Construct form opcode- Parameters:
opcode
- the opcode the frame is based on
-
-
Method Details
-
copy
-
assertValid
public abstract void assertValid() -
copyHeaders
-
copyHeaders
-
equals
-
getMask
public byte[] getMask() -
getOpCode
public final byte getOpCode() -
getPayload
Get the payload ByteBuffer. possible null.- Specified by:
getPayload
in interfaceFrame
-
getPayloadAsUTF8
-
getPayloadLength
public int getPayloadLength()Description copied from interface:Frame
The original payload length (Buffer.remaining()
)- Specified by:
getPayloadLength
in interfaceFrame
- Returns:
- the original payload length (
Buffer.remaining()
)
-
getType
-
hashCode
public int hashCode() -
hasPayload
public boolean hasPayload()- Specified by:
hasPayload
in interfaceFrame
-
isControlFrame
public abstract boolean isControlFrame() -
isDataFrame
public abstract boolean isDataFrame() -
isFin
public boolean isFin() -
isLast
public boolean isLast()Description copied from interface:Frame
Same asFrame.isFin()
-
isMasked
public boolean isMasked() -
isRsv1
public boolean isRsv1() -
isRsv2
public boolean isRsv2() -
isRsv3
public boolean isRsv3() -
reset
public void reset() -
setFin
-
setMask
-
setMasked
-
setOpCode
-
setPayload
Set the data payload.The provided buffer will be used as is, no copying of bytes performed.
The provided buffer should be flipped and ready to READ from.
- Parameters:
buf
- the bytebuffer to set- Returns:
- the frame itself
-
setRsv1
-
setRsv2
-
setRsv3
-
toString
-