Package org.glassfish.grizzly.websockets
Class ProtocolHandler
java.lang.Object
org.glassfish.grizzly.websockets.ProtocolHandler
- Direct Known Subclasses:
RFC6455Handler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.glassfish.grizzly.Connectionprotected org.glassfish.grizzly.filterchain.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) org.glassfish.grizzly.GrizzlyFuture<DataFrame>abstract HandShakecreateClientHandShake(URI uri) abstract HandShakecreateServerHandShake(org.glassfish.grizzly.http.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) org.glassfish.grizzly.Connectionorg.glassfish.grizzly.filterchain.FilterChainContextprotected WebSocketMappingDatahandshake(org.glassfish.grizzly.filterchain.FilterChainContext ctx, WebSocketApplication app, org.glassfish.grizzly.http.HttpContent request) protected abstract booleanisControlFrame(byte opcode) booleanabstract DataFrameparse(org.glassfish.grizzly.Buffer buffer) org.glassfish.grizzly.GrizzlyFuture<DataFrame>send(byte[] data) org.glassfish.grizzly.GrizzlyFuture<DataFrame>final org.glassfish.grizzly.GrizzlyFuture<DataFrame>org.glassfish.grizzly.GrizzlyFuture<DataFrame>voidsetConnection(org.glassfish.grizzly.Connection handler) voidsetFilterChainContext(org.glassfish.grizzly.filterchain.FilterChainContext ctx) protected voidsetMappingData(WebSocketMappingData mappingData) voidsetWebSocket(WebSocket webSocket) org.glassfish.grizzly.GrizzlyFuture<DataFrame>stream(boolean last, byte[] bytes, int off, int len) org.glassfish.grizzly.GrizzlyFuture<DataFrame>toDataFrame(byte[] data) toDataFrame(byte[] data, boolean last) toDataFrame(String data) toDataFrame(String data, boolean last) unframe(org.glassfish.grizzly.Buffer buffer) protected voidutf8Decode(boolean finalFragment, byte[] data, DataFrame dataFrame) protected voidvalidate(byte fragmentType, byte opcode)
-
Field Details
-
connection
protected org.glassfish.grizzly.Connection connection -
inFragmentedType
protected byte inFragmentedType -
outFragmentedType
protected byte outFragmentedType -
maskData
protected final boolean maskData -
ctx
protected org.glassfish.grizzly.filterchain.FilterChainContext ctx -
processingFragment
protected boolean processingFragment -
utf8
-
currentDecoder
-
remainder
-
mappingData
-
-
Constructor Details
-
ProtocolHandler
public ProtocolHandler(boolean maskData)
-
-
Method Details
-
handshake
public HandShake handshake(org.glassfish.grizzly.filterchain.FilterChainContext ctx, WebSocketApplication app, org.glassfish.grizzly.http.HttpContent request) -
send
-
send
-
getConnection
public org.glassfish.grizzly.Connection getConnection() -
setConnection
public void setConnection(org.glassfish.grizzly.Connection handler) -
getFilterChainContext
public org.glassfish.grizzly.filterchain.FilterChainContext getFilterChainContext() -
setFilterChainContext
public void setFilterChainContext(org.glassfish.grizzly.filterchain.FilterChainContext ctx) -
getMappingData
-
setMappingData
-
getWebSocket
-
setWebSocket
-
isMaskData
public boolean isMaskData() -
frame
-
toDataFrame
-
toDataFrame
-
toDataFrame
-
toDataFrame
-
createServerHandShake
public abstract HandShake createServerHandShake(org.glassfish.grizzly.http.HttpContent requestContent) -
createClientHandShake
-
send
-
send
-
stream
public org.glassfish.grizzly.GrizzlyFuture<DataFrame> stream(boolean last, byte[] bytes, int off, int len) -
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
-