Class ProtocolHandler

java.lang.Object
org.glassfish.grizzly.websockets.ProtocolHandler
Direct Known Subclasses:
RFC6455Handler

public abstract class ProtocolHandler extends Object
  • 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

      protected final Charset utf8
    • currentDecoder

      protected final CharsetDecoder currentDecoder
    • remainder

      protected ByteBuffer remainder
    • mappingData

      protected WebSocketMappingData 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

      public final org.glassfish.grizzly.GrizzlyFuture<DataFrame> send(DataFrame frame)
    • send

      public org.glassfish.grizzly.GrizzlyFuture<DataFrame> send(DataFrame frame, org.glassfish.grizzly.CompletionHandler<DataFrame> completionHandler)
    • 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

      protected WebSocketMappingData getMappingData()
    • setMappingData

      protected void setMappingData(WebSocketMappingData mappingData)
    • getWebSocket

      public WebSocket getWebSocket()
    • setWebSocket

      public void setWebSocket(WebSocket webSocket)
    • isMaskData

      public boolean isMaskData()
    • frame

      public abstract byte[] frame(DataFrame frame)
    • toDataFrame

      public DataFrame toDataFrame(String data)
    • toDataFrame

      public DataFrame toDataFrame(byte[] data)
    • toDataFrame

      public DataFrame toDataFrame(String data, boolean last)
    • toDataFrame

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

      public abstract HandShake createServerHandShake(org.glassfish.grizzly.http.HttpContent requestContent)
    • createClientHandShake

      public abstract HandShake createClientHandShake(URI uri)
    • send

      public org.glassfish.grizzly.GrizzlyFuture<DataFrame> send(byte[] data)
    • send

      public org.glassfish.grizzly.GrizzlyFuture<DataFrame> send(String data)
    • stream

      public org.glassfish.grizzly.GrizzlyFuture<DataFrame> stream(boolean last, byte[] bytes, int off, int len)
    • stream

      public org.glassfish.grizzly.GrizzlyFuture<DataFrame> stream(boolean last, String fragment)
    • close

      public org.glassfish.grizzly.GrizzlyFuture<DataFrame> close(int code, String reason)
    • unframe

      public DataFrame unframe(org.glassfish.grizzly.Buffer buffer)
    • parse

      public abstract DataFrame parse(org.glassfish.grizzly.Buffer buffer)
    • 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:
      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 - the payload size
      Returns:
      the array
    • validate

      protected void validate(byte fragmentType, byte opcode)
    • isControlFrame

      protected abstract boolean isControlFrame(byte opcode)
    • checkForLastFrame

      protected byte checkForLastFrame(DataFrame frame, byte opcode)
    • doClose

      public void doClose()
    • utf8Decode

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

      protected ByteBuffer getByteBuffer(byte[] data)