Interface WebSocketHandler
-
- All Known Implementing Classes:
WebSocketHandlerImpl
public interface WebSocketHandlerHandles states for the web socket.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classWebSocketHandler.WebSocketMessageTypeStates when parsing a frame.static classWebSocketHandler.WebsocketTupleRepresents the web socket message and its type.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcalculateHeaderSize(int payloadSize)Gets the size of the header.voidcreatePong(java.nio.ByteBuffer srcBuffer, java.nio.ByteBuffer dstBuffer)Creates the pong for the "keep-alive", heart beat, network status probing when connecting in a web socket.java.lang.StringcreateUpgradeRequest(java.lang.String hostName, java.lang.String webSocketPath, java.lang.String webSocketQuery, int webSocketPort, java.lang.String webSocketProtocol, java.util.Map<java.lang.String,java.lang.String> additionalHeaders)Creates an HTTP request to upgrade to use web sockets.WebSocketHandler.WebsocketTupleunwrapBuffer(java.nio.ByteBuffer srcBuffer)Unwraps the layer from the buffer.java.lang.BooleanvalidateUpgradeReply(java.nio.ByteBuffer buffer)Validates the response.voidwrapBuffer(java.nio.ByteBuffer srcBuffer, java.nio.ByteBuffer dstBuffer)Wraps the source buffer with additional contents from the web socket.
-
-
-
Method Detail
-
createUpgradeRequest
java.lang.String createUpgradeRequest(java.lang.String hostName, java.lang.String webSocketPath, java.lang.String webSocketQuery, int webSocketPort, java.lang.String webSocketProtocol, java.util.Map<java.lang.String,java.lang.String> additionalHeaders)Creates an HTTP request to upgrade to use web sockets.- Parameters:
hostName- Name of the host.webSocketPath- Path for the websocket.webSocketQuery- Query for the web socket.webSocketPort- Port for web socket.webSocketProtocol- Protocol to use for web sockets.additionalHeaders- Any additional headers to add to the HTTP upgrade request.- Returns:
- Represents the HTTP request.
-
validateUpgradeReply
java.lang.Boolean validateUpgradeReply(java.nio.ByteBuffer buffer)
Validates the response.- Parameters:
buffer- ByteBuffer to read from.- Returns:
- True if the response is valid, otherwise, false.
-
wrapBuffer
void wrapBuffer(java.nio.ByteBuffer srcBuffer, java.nio.ByteBuffer dstBuffer)Wraps the source buffer with additional contents from the web socket.- Parameters:
srcBuffer- Source buffer to wrap input.dstBuffer- Output buffer that bytes are written to.
-
unwrapBuffer
WebSocketHandler.WebsocketTuple unwrapBuffer(java.nio.ByteBuffer srcBuffer)
Unwraps the layer from the buffer.- Parameters:
srcBuffer- The source buffer.- Returns:
- The current chunk for the web socket when reading.
-
createPong
void createPong(java.nio.ByteBuffer srcBuffer, java.nio.ByteBuffer dstBuffer)Creates the pong for the "keep-alive", heart beat, network status probing when connecting in a web socket.- Parameters:
srcBuffer- The source buffer to read from.dstBuffer- The destination buffer with the pong.- See Also:
- Ping and pong
-
calculateHeaderSize
int calculateHeaderSize(int payloadSize)
Gets the size of the header.- Parameters:
payloadSize- Size of the payload.- Returns:
- The size of the header.
-
-