public class WebSocketFrame
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
frameLengthOverhead |
| Constructor and Description |
|---|
WebSocketFrame(byte[] rawFrame)
Initialise WebSocketFrame from raw Data
|
WebSocketFrame(byte opcode,
boolean fin,
byte[] payload)
Initialise a new WebSocketFrame
|
WebSocketFrame(java.io.InputStream input)
Takes an input stream and parses it into a Websocket frame.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
appendFinAndOpCode(java.nio.ByteBuffer buffer,
byte opcode,
boolean fin)
Appends the Fin flag and the OpCode
|
static void |
appendLengthAndMask(java.nio.ByteBuffer buffer,
int length,
byte[] mask)
Appends the Length and Mask to the buffer
|
byte[] |
encodeFrame()
Encodes the this WebSocketFrame into a byte array.
|
static byte[] |
generateMaskingKey()
Generates a random masking key
Nothing super secure, but enough
for websockets.
|
byte |
getOpcode() |
byte[] |
getPayload() |
boolean |
isCloseFlag() |
boolean |
isFin() |
public static final int frameLengthOverhead
public WebSocketFrame(byte opcode,
boolean fin,
byte[] payload)
opcode - fin - payload - public WebSocketFrame(byte[] rawFrame)
rawFrame - public WebSocketFrame(java.io.InputStream input)
throws java.io.IOException
input - java.io.IOExceptionpublic byte getOpcode()
public boolean isFin()
public byte[] getPayload()
public boolean isCloseFlag()
public byte[] encodeFrame()
public static void appendLengthAndMask(java.nio.ByteBuffer buffer,
int length,
byte[] mask)
buffer - length - mask - public static void appendFinAndOpCode(java.nio.ByteBuffer buffer,
byte opcode,
boolean fin)
buffer - opcode - fin - public static byte[] generateMaskingKey()