public class WSUtils
extends java.lang.Object
Constructor | Description |
---|---|
WSUtils() |
Modifier and Type | Method | Description |
---|---|---|
static int |
getFrameLength(java.nio.ByteBuffer bb) |
Gives the total length of the next Frame in the provided
ByteBuffer . |
static int |
getFrameLength(org.threadly.litesockets.buffers.MergedByteBuffers mbb) |
Gives the total length of the next Frame in the provided
MergedByteBuffers . |
static java.lang.String |
makeKeyResponse(java.lang.String str) |
Makes a Sec-WebSocket-Key response string.
|
static java.lang.String |
makeSecretKey() |
Makes a Sec-WebSocket-Key that is 20 Bytes long.
|
static java.lang.String |
makeSecretKey(int size) |
Makes a Sec-WebSocket-Key that is however long you make it.
|
static java.nio.ByteBuffer |
maskData(java.nio.ByteBuffer nbb,
int mask) |
This will mask or unmask data against provided mask.
|
static boolean |
validateKeyResponse(java.lang.String orig,
java.lang.String response) |
Validates the Sec-WebSocket-Accept header response for a websocket request.
|
static boolean |
validateKeyResponse(java.lang.String origKey,
HTTPHeaders headers) |
Validates the Sec-WebSocket-Accept header response for a websocket request.
|
public static java.lang.String makeSecretKey()
public static java.lang.String makeSecretKey(int size)
size
- the size in bytes of the random key.public static java.lang.String makeKeyResponse(java.lang.String str)
str
- base64 string passed in the Sec-WebSocket-Key header.public static boolean validateKeyResponse(java.lang.String origKey, HTTPHeaders headers)
origKey
- the original key used.headers
- the HTTPHeader objectpublic static boolean validateKeyResponse(java.lang.String orig, java.lang.String response)
origKey
- the original key used.response
- the String value of the response.public static java.nio.ByteBuffer maskData(java.nio.ByteBuffer nbb, int mask)
nbb
- the ByteBuffer
to apply the mask to.mask
- the mask to apply to the ByteBuffer.ByteBuffer
with the provided mask applyed to it.public static int getFrameLength(org.threadly.litesockets.buffers.MergedByteBuffers mbb)
MergedByteBuffers
.
This does not modify the MergedByteBuffers
.mbb
- MergedByteBuffers
to get the Frame length from.public static int getFrameLength(java.nio.ByteBuffer bb)
ByteBuffer
.
This does not modify the ByteBuffer
.bb
- the ByteBuffer
to find the frame length on.ByteBuffer
.