public abstract class ProtocolHandler extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Connection |
connection |
protected CharsetDecoder |
currentDecoder |
protected byte |
inFragmentedType |
protected boolean |
maskData |
protected byte |
outFragmentedType |
protected boolean |
processingFragment |
protected ByteBuffer |
remainder |
protected Charset |
utf8 |
| Constructor and Description |
|---|
ProtocolHandler(boolean maskData) |
| Modifier and Type | Method and Description |
|---|---|
protected byte |
checkForLastFrame(DataFrame frame,
byte opcode) |
Future<DataFrame> |
close(int code,
String reason) |
abstract HandShake |
createHandShake(URI uri)
Client side.
|
abstract HandShake |
createHandShake(WebSocketRequest requestContent)
Server side.
|
long |
decodeLength(byte[] bytes)
Convert a byte[] to a long.
|
void |
doClose() |
byte[] |
encodeLength(long length)
Converts the length given to the appropriate framing data: 0-125 one element that is the payload length.
|
abstract byte[] |
frame(DataFrame frame) |
protected ByteBuffer |
getByteBuffer(byte[] data) |
Connection |
getConnection() |
WebSocket |
getWebSocket() |
HandShake |
handshake(Connection connection,
WebSocketApplication app,
WebSocketRequest request) |
protected abstract boolean |
isControlFrame(byte opcode) |
boolean |
isMaskData() |
abstract DataFrame |
parse(ByteBuffer buffer) |
Future<DataFrame> |
send(byte[] data) |
Future<DataFrame> |
send(DataFrame frame) |
Future<DataFrame> |
send(DataFrame frame,
Connection.CompletionHandler<DataFrame> completionHandler) |
Future<DataFrame> |
send(String data) |
void |
setConnection(Connection handler) |
void |
setWebSocket(WebSocket webSocket) |
Future<DataFrame> |
stream(boolean last,
byte[] bytes,
int off,
int len) |
Future<DataFrame> |
stream(boolean last,
String fragment) |
DataFrame |
unframe(ByteBuffer buffer) |
protected void |
utf8Decode(boolean finalFragment,
byte[] data,
DataFrame dataFrame) |
protected void |
validate(byte fragmentType,
byte opcode) |
protected Connection connection
protected byte inFragmentedType
protected byte outFragmentedType
protected final boolean maskData
protected boolean processingFragment
protected Charset utf8
protected CharsetDecoder currentDecoder
protected ByteBuffer remainder
public HandShake handshake(Connection connection, WebSocketApplication app, WebSocketRequest request)
public Future<DataFrame> send(DataFrame frame, Connection.CompletionHandler<DataFrame> completionHandler)
public Connection getConnection()
public void setConnection(Connection handler)
public WebSocket getWebSocket()
public void setWebSocket(WebSocket webSocket)
public boolean isMaskData()
public abstract byte[] frame(DataFrame frame)
public abstract HandShake createHandShake(WebSocketRequest requestContent)
requestContent - TODOpublic abstract HandShake createHandShake(URI uri)
uri - TODOpublic DataFrame unframe(ByteBuffer buffer)
public abstract DataFrame parse(ByteBuffer buffer)
public long decodeLength(byte[] bytes)
bytes - TODOpublic byte[] encodeLength(long length)
length - the payload sizeprotected void validate(byte fragmentType,
byte opcode)
protected abstract boolean isControlFrame(byte opcode)
protected byte checkForLastFrame(DataFrame frame, byte opcode)
public void doClose()
protected void utf8Decode(boolean finalFragment,
byte[] data,
DataFrame dataFrame)
protected ByteBuffer getByteBuffer(byte[] data)
Copyright © 2012-2013. All Rights Reserved.