Top Fields Constructors Methods
org.glassfish.grizzly.websockets

public abstract Class ProtocolHandler

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.grizzly.websockets.rfc6455.RFC6455Handler
Imports
java.net.URI, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetDecoder, .CoderResult, org.glassfish.grizzly.Buffer, .CompletionHandler, .Connection, .EmptyCompletionHandler, .GrizzlyFuture, org.glassfish.grizzly.filterchain.FilterChainContext, org.glassfish.grizzly.http.HttpContent, .HttpRequestPacket, .HttpResponsePacket, org.glassfish.grizzly.impl.FutureImpl, .SafeFutureImpl, org.glassfish.grizzly.utils.Charsets, org.glassfish.grizzly.websockets.frametypes.BinaryFrameType, .TextFrameType

Field Summary

Modifier and TypeField and Description
protected Connection<L>
protected FilterChainContext
protected final CharsetDecoder
protected byte
protected WebSocketMappingData
protected final boolean
protected byte
protected boolean
protected ByteBuffer
protected final Charset
private WebSocket

Constructor Summary

AccessConstructor and Description
public
ProtocolHandler(boolean maskData)

Method Summary

Modifier and TypeMethod and Description
protected byte
checkForLastFrame(DataFrame frame, byte opcode)

public GrizzlyFuture<DataFrame>
close(int code, String reason)

public abstract HandShake
public abstract HandShake
public long
decodeLength(byte[] bytes)

Convert a byte[] to a long.

public void
public byte[]

Returns:

the array
encodeLength
(final long
the payload size
length
)

Converts the length given to the appropriate framing data:

  1. 0-125 one element that is the payload length.
  2. 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.
  3. 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.
public abstract byte[]
protected ByteBuffer
getByteBuffer(final byte[] data)

public Connection<L>
public FilterChainContext
protected WebSocketMappingData
public WebSocket
public HandShake
protected abstract boolean
isControlFrame(byte opcode)

public boolean
public abstract DataFrame
parse(Buffer buffer)

public final GrizzlyFuture<DataFrame>
send(DataFrame frame)

public GrizzlyFuture<DataFrame>
send(DataFrame frame, CompletionHandler<DataFrame> completionHandler)

public GrizzlyFuture<DataFrame>
send(byte[] data)

public GrizzlyFuture<DataFrame>
send(String data)

public void
public void
protected void
public void
public GrizzlyFuture<DataFrame>
stream(boolean last, byte[] bytes, int off, int len)

public GrizzlyFuture<DataFrame>
stream(boolean last, String fragment)

public DataFrame
public DataFrame
toDataFrame(byte[] data)

public DataFrame
toDataFrame(String data, boolean last)

public DataFrame
toDataFrame(byte[] data, boolean last)

public DataFrame
unframe(Buffer buffer)

protected void
utf8Decode(boolean finalFragment, byte[] data, DataFrame dataFrame)

protected void
validate(final byte fragmentType, byte opcode)

private GrizzlyFuture<DataFrame>
write(final DataFrame frame, final CompletionHandler<DataFrame> completionHandler)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionback to summary
protected Connection<L> connection
ctxback to summary
protected FilterChainContext ctx
currentDecoderback to summary
protected final CharsetDecoder currentDecoder
inFragmentedTypeback to summary
protected byte inFragmentedType
mappingDataback to summary
protected WebSocketMappingData mappingData
maskDataback to summary
protected final boolean maskData
outFragmentedTypeback to summary
protected byte outFragmentedType
processingFragmentback to summary
protected boolean processingFragment
remainderback to summary
protected ByteBuffer remainder
utf8back to summary
protected final Charset utf8
webSocketback to summary
private WebSocket webSocket

Constructor Detail

ProtocolHandlerback to summary
public ProtocolHandler(boolean maskData)

Method Detail

checkForLastFrameback to summary
protected byte checkForLastFrame(DataFrame frame, byte opcode)
closeback to summary
public GrizzlyFuture<DataFrame> close(int code, String reason)
createClientHandShakeback to summary
public abstract HandShake createClientHandShake(URI uri)
createServerHandShakeback to summary
public abstract HandShake createServerHandShake(HttpContent requestContent)
decodeLengthback to summary
public long decodeLength(byte[] bytes)

Convert a byte[] to a long. Used for rebuilding payload length.

doCloseback to summary
public void doClose()
encodeLengthback to summary
public byte[] encodeLength(final long length)

Converts the length given to the appropriate framing data:

  1. 0-125 one element that is the payload length.
  2. 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.
  3. 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:long

the payload size

Returns:byte[]

the array

frameback to summary
public abstract byte[] frame(DataFrame frame)
getByteBufferback to summary
protected ByteBuffer getByteBuffer(final byte[] data)
getConnectionback to summary
public Connection<L> getConnection()
getFilterChainContextback to summary
public FilterChainContext getFilterChainContext()
getMappingDataback to summary
protected WebSocketMappingData getMappingData()
getWebSocketback to summary
public WebSocket getWebSocket()
handshakeback to summary
public HandShake handshake(FilterChainContext ctx, WebSocketApplication app, HttpContent request)
isControlFrameback to summary
protected abstract boolean isControlFrame(byte opcode)
isMaskDataback to summary
public boolean isMaskData()
parseback to summary
public abstract DataFrame parse(Buffer buffer)
sendback to summary
public final GrizzlyFuture<DataFrame> send(DataFrame frame)
sendback to summary
public GrizzlyFuture<DataFrame> send(DataFrame frame, CompletionHandler<DataFrame> completionHandler)
sendback to summary
public GrizzlyFuture<DataFrame> send(byte[] data)
sendback to summary
public GrizzlyFuture<DataFrame> send(String data)
setConnectionback to summary
public void setConnection(Connection<L> handler)
setFilterChainContextback to summary
public void setFilterChainContext(FilterChainContext ctx)
setMappingDataback to summary
protected void setMappingData(final WebSocketMappingData mappingData)
setWebSocketback to summary
public void setWebSocket(WebSocket webSocket)
streamback to summary
public GrizzlyFuture<DataFrame> stream(boolean last, byte[] bytes, int off, int len)
streamback to summary
public GrizzlyFuture<DataFrame> stream(boolean last, String fragment)
toDataFrameback to summary
public DataFrame toDataFrame(String data)
toDataFrameback to summary
public DataFrame toDataFrame(byte[] data)
toDataFrameback to summary
public DataFrame toDataFrame(String data, boolean last)
toDataFrameback to summary
public DataFrame toDataFrame(byte[] data, boolean last)
unframeback to summary
public DataFrame unframe(Buffer buffer)
utf8Decodeback to summary
protected void utf8Decode(boolean finalFragment, byte[] data, DataFrame dataFrame)
validateback to summary
protected void validate(final byte fragmentType, byte opcode)
writeback to summary
private GrizzlyFuture<DataFrame> write(final DataFrame frame, final CompletionHandler<DataFrame> completionHandler)
Annotations
@SuppressWarnings:unchecked