Interface ExtensionFunction

  • All Known Implementing Classes:
    CompositeExtensionFunction, NoopExtensionFunction, PerMessageDeflateFunction

    public interface ExtensionFunction
    Base interface for WebSocket Extensions implementation.

    It interacts at the connection phase. It is responsible to apply extension's logic before to write and after to read to/from a WebSocket Endpoint.

    Several extensions can be present in a WebSocket Endpoint being executed in a chain pattern.

    Extension state is stored per WebSocket connection.

    Author:
    Lucas Ponce
    • Method Detail

      • hasExtensionOpCode

        boolean hasExtensionOpCode()
        Validate if current extension defines a new WebSocket Opcode.
        Returns:
        true if current extension defines specific Opcode false is current extension does not define specific Opcode
        See Also:
        WebSocket Base Framing Protocol Reference
      • writeRsv

        int writeRsv​(int rsv)
        Add RSV bits (RSV1, RSV2, RSV3) to the current rsv status.
        Parameters:
        rsv - current RSV bits status
        Returns:
        rsv status
      • transformForWrite

        PooledByteBuffer transformForWrite​(PooledByteBuffer pooledBuffer,
                                           StreamSinkFrameChannel channel,
                                           boolean lastFrame)
                                    throws IOException
        Transform the supplied buffer per this extension. The buffer can be modified in place, or a new pooled buffer can be returned (in which case be sure to free the original buffer
        Parameters:
        pooledBuffer - Buffer to transform
        channel - working channel
        Returns:
        transformed buffer (may be the same one, just with modified contents)
        Throws:
        IOException
      • transformForRead

        PooledByteBuffer transformForRead​(PooledByteBuffer pooledBuffer,
                                          StreamSourceFrameChannel channel,
                                          boolean lastFragmentOfMessage)
                                   throws IOException
        Transform the supplied buffer per this extension. The buffer can be modified in place, or a new pooled buffer can be returned (in which case be sure to free the original buffer
        Parameters:
        pooledBuffer - Buffer to transform
        channel - working channel
        lastFragmentOfMessage - If this frame is the last fragment of a message. Note that this may not be received for every message, if the message ends with an empty frame
        Returns:
        transformed buffer (may be the same one, just with modified contents)
        Throws:
        IOException
      • dispose

        void dispose()
        Dispose this function. Called upon connection closure