public class WebsocketFrameHeader
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
WebsocketFrameHeader.OpCode |
Modifier and Type | Field and Description |
---|---|
static int |
MAX_FRAME_HEADER_SIZE |
Constructor and Description |
---|
WebsocketFrameHeader() |
Modifier and Type | Method and Description |
---|---|
int |
filterPayload(byte[] buffer,
int offset,
int length)
Decrement the payloadLength by at most maxSize such that payloadLength is non-negative,
returning the amount decremented.
|
int |
getMaskingKey() |
WebsocketFrameHeader.OpCode |
getOpCode() |
long |
getPayloadLength() |
boolean |
isFinal() |
boolean |
isMasked() |
boolean |
isPayloadEmpty() |
int |
read(byte[] buffer,
int offset,
int length)
Serializes this WebsocketFrameHeader into a buffer.
|
int |
size() |
static int |
size(byte[] buffer,
int offset)
Introspects the first 2 bytes of buffer at the specified offset to
determine how large the entire header is.
|
WebsocketFrameHeader |
withMask(int maskingKey) |
WebsocketFrameHeader |
withNoMask() |
WebsocketFrameHeader |
withOp(WebsocketFrameHeader.OpCode op,
boolean isFinal) |
WebsocketFrameHeader |
withPayloadLength(long payloadLength) |
int |
write(byte[] buffer,
int offset,
int length)
Overwrite internal frame header content with input buffer.
|
public WebsocketFrameHeader withOp(WebsocketFrameHeader.OpCode op, boolean isFinal)
public WebsocketFrameHeader withNoMask()
public WebsocketFrameHeader withMask(int maskingKey)
public WebsocketFrameHeader withPayloadLength(long payloadLength)
public boolean isFinal()
public boolean isMasked()
public int getMaskingKey()
public long getPayloadLength()
public WebsocketFrameHeader.OpCode getOpCode()
public boolean isPayloadEmpty()
public int filterPayload(byte[] buffer, int offset, int length)
buffer
- is the buffer to filter.offset
- is the start offset within buffer to filter.length
- is the number of bytes to filter.public int size()
public static int size(byte[] buffer, int offset)
buffer
- is the buffer to introspectoffset
- is the offset within the buffer where the websocket
header begins.public int read(byte[] buffer, int offset, int length)
buffer
- where the serialized header will be placed.offset
- is the start offset into the buffer.length
- is the max bytes that can be placed in the buffer.public int write(byte[] buffer, int offset, int length)
WebsocketFrameHeader header = new WebsocketFrameHeader(); int consumedLength = header.write(buffer, offset, length); offset += consumedLength; length -= consumedLength;
buffer
- containing the serialized header.offset
- is the start offset into the buffer.length
- is the max bytes to consume.