public abstract class WebSocketFrame extends Object implements Frame
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 ... | +---------------------------------------------------------------+
Frame.Type
Modifier and Type | Field and Description |
---|---|
protected ByteBuffer |
data
The payload data.
|
protected byte |
finRsvOp
Combined FIN + RSV1 + RSV2 + RSV3 + OpCode byte.
|
protected byte[] |
mask |
protected boolean |
masked |
Modifier | Constructor and Description |
---|---|
protected |
WebSocketFrame(byte opcode)
Construct form opcode
|
Modifier and Type | Method and Description |
---|---|
abstract void |
assertValid() |
static WebSocketFrame |
copy(Frame original) |
protected void |
copyHeaders(Frame frame) |
protected void |
copyHeaders(WebSocketFrame copy) |
boolean |
equals(Object obj) |
byte[] |
getMask() |
byte |
getOpCode() |
ByteBuffer |
getPayload()
Get the payload ByteBuffer.
|
String |
getPayloadAsUTF8() |
int |
getPayloadLength()
The original payload length (
Buffer.remaining() ) |
Frame.Type |
getType() |
int |
hashCode() |
boolean |
hasPayload() |
abstract boolean |
isControlFrame() |
abstract boolean |
isDataFrame() |
boolean |
isFin() |
boolean |
isLast()
Same as
Frame.isFin() |
boolean |
isMasked() |
boolean |
isRsv1() |
boolean |
isRsv2() |
boolean |
isRsv3() |
void |
reset() |
WebSocketFrame |
setFin(boolean fin) |
Frame |
setMask(byte[] maskingKey) |
Frame |
setMasked(boolean mask) |
protected WebSocketFrame |
setOpCode(byte op) |
WebSocketFrame |
setPayload(ByteBuffer buf)
Set the data payload.
|
WebSocketFrame |
setRsv1(boolean rsv1) |
WebSocketFrame |
setRsv2(boolean rsv2) |
WebSocketFrame |
setRsv3(boolean rsv3) |
String |
toString() |
protected byte finRsvOp
1000_0000 (0x80) = fin 0100_0000 (0x40) = rsv1 0010_0000 (0x20) = rsv2 0001_0000 (0x10) = rsv3 0000_1111 (0x0F) = opcode
protected boolean masked
protected byte[] mask
protected ByteBuffer data
It is assumed to always be in FLUSH mode (ready to read) in this object.
public static WebSocketFrame copy(Frame original)
public abstract void assertValid()
protected void copyHeaders(Frame frame)
protected void copyHeaders(WebSocketFrame copy)
public ByteBuffer getPayload()
getPayload
in interface Frame
public String getPayloadAsUTF8()
public int getPayloadLength()
Frame
Buffer.remaining()
)getPayloadLength
in interface Frame
Buffer.remaining()
)public Frame.Type getType()
public boolean hasPayload()
hasPayload
in interface Frame
public abstract boolean isControlFrame()
public abstract boolean isDataFrame()
public boolean isLast()
Frame
Frame.isFin()
public void reset()
public WebSocketFrame setFin(boolean fin)
public Frame setMask(byte[] maskingKey)
public Frame setMasked(boolean mask)
protected WebSocketFrame setOpCode(byte op)
public WebSocketFrame setPayload(ByteBuffer buf)
The provided buffer will be used as is, no copying of bytes performed.
The provided buffer should be flipped and ready to READ from.
buf
- the bytebuffer to setpublic WebSocketFrame setRsv1(boolean rsv1)
public WebSocketFrame setRsv2(boolean rsv2)
public WebSocketFrame setRsv3(boolean rsv3)
Copyright © 1995-2015 Webtide. All Rights Reserved.