Package org.glassfish.grizzly.websockets
Class ProtocolHandler
java.lang.Object
org.glassfish.grizzly.websockets.ProtocolHandler
- Direct Known Subclasses:
RFC6455Handler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Connectionprotected FilterChainContextprotected final CharsetDecoderprotected byteprotected WebSocketMappingDataprotected final booleanprotected byteprotected booleanprotected ByteBufferprotected final Charset -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected bytecheckForLastFrame(DataFrame frame, byte opcode) abstract HandShakecreateClientHandShake(URI uri) abstract HandShakecreateServerHandShake(HttpContent requestContent) longdecodeLength(byte[] bytes) Convert a byte[] to a long.voiddoClose()byte[]encodeLength(long length) Converts the length given to the appropriate framing data: 0-125 one element that is the payload length.abstract byte[]protected ByteBuffergetByteBuffer(byte[] data) protected WebSocketMappingDatahandshake(FilterChainContext ctx, WebSocketApplication app, HttpContent request) protected abstract booleanisControlFrame(byte opcode) booleanabstract DataFramesend(byte[] data) final GrizzlyFuture<DataFrame>send(DataFrame frame, CompletionHandler<DataFrame> completionHandler) voidsetConnection(Connection handler) voidprotected voidsetMappingData(WebSocketMappingData mappingData) voidsetWebSocket(WebSocket webSocket) stream(boolean last, byte[] bytes, int off, int len) toDataFrame(byte[] data) toDataFrame(byte[] data, boolean last) toDataFrame(String data) toDataFrame(String data, boolean last) protected voidutf8Decode(boolean finalFragment, byte[] data, DataFrame dataFrame) protected voidvalidate(byte fragmentType, byte opcode)
-
Field Details
-
connection
-
inFragmentedType
protected byte inFragmentedType -
outFragmentedType
protected byte outFragmentedType -
maskData
protected final boolean maskData -
ctx
-
processingFragment
protected boolean processingFragment -
utf8
-
currentDecoder
-
remainder
-
mappingData
-
-
Constructor Details
-
ProtocolHandler
public ProtocolHandler(boolean maskData)
-
-
Method Details
-
handshake
-
send
-
send
public GrizzlyFuture<DataFrame> send(DataFrame frame, CompletionHandler<DataFrame> completionHandler) -
getConnection
-
setConnection
-
getFilterChainContext
-
setFilterChainContext
-
getMappingData
-
setMappingData
-
getWebSocket
-
setWebSocket
-
isMaskData
public boolean isMaskData() -
frame
-
toDataFrame
-
toDataFrame
-
toDataFrame
-
toDataFrame
-
createServerHandShake
-
createClientHandShake
-
send
-
send
-
stream
-
stream
-
close
-
unframe
-
parse
-
decodeLength
public long decodeLength(byte[] bytes) Convert a byte[] to a long. Used for rebuilding payload length. -
encodeLength
public byte[] encodeLength(long length) Converts the length given to the appropriate framing data:- 0-125 one element that is the payload length.
- up to 0xFFFF, 3 element array starting with 126 with the following 2 bytes interpreted as a 16 bit unsigned integer showing the payload length.
- else 9 element array starting with 127 with the following 8 bytes interpreted as a 64-bit unsigned integer (the high bit must be 0) showing the payload length.
- Parameters:
length- the payload size- Returns:
- the array
-
validate
protected void validate(byte fragmentType, byte opcode) -
isControlFrame
protected abstract boolean isControlFrame(byte opcode) -
checkForLastFrame
-
doClose
public void doClose() -
utf8Decode
-
getByteBuffer
-