Class PerMessageDeflateFunction

  • All Implemented Interfaces:
    ExtensionFunction

    public class PerMessageDeflateFunction
    extends Object
    implements ExtensionFunction
    Implementation of permessage-deflate WebSocket Extension.

    This implementation supports parameters: server_no_context_takeover, client_no_context_takeover .

    This implementation does not support parameters: server_max_window_bits, client_max_window_bits .

    It uses the DEFLATE implementation algorithm packaged on Deflater and Inflater classes.

    Author:
    Lucas Ponce
    See Also:
    Compression Extensions for WebSocket
    • Constructor Detail

      • PerMessageDeflateFunction

        public PerMessageDeflateFunction​(int deflaterLevel,
                                         boolean compressContextTakeover,
                                         boolean decompressContextTakeover)
        Create a new PerMessageDeflateExtension instance.
        Parameters:
        deflaterLevel - the level of configuration of DEFLATE algorithm implementation
        compressContextTakeover - flag for compressor context takeover or without compressor context
        decompressContextTakeover - flag for decompressor context takeover or without decompressor context
    • Method Detail

      • writeRsv

        public int writeRsv​(int rsv)
        Description copied from interface: ExtensionFunction
        Add RSV bits (RSV1, RSV2, RSV3) to the current rsv status.
        Specified by:
        writeRsv in interface ExtensionFunction
        Parameters:
        rsv - current RSV bits status
        Returns:
        rsv status
      • transformForWrite

        public PooledByteBuffer transformForWrite​(PooledByteBuffer pooledBuffer,
                                                  StreamSinkFrameChannel channel,
                                                  boolean lastFrame)
                                           throws IOException
        Description copied from interface: ExtensionFunction
        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
        Specified by:
        transformForWrite in interface ExtensionFunction
        Parameters:
        pooledBuffer - Buffer to transform
        channel - working channel
        Returns:
        transformed buffer (may be the same one, just with modified contents)
        Throws:
        IOException
      • transformForRead

        public PooledByteBuffer transformForRead​(PooledByteBuffer pooledBuffer,
                                                 StreamSourceFrameChannel channel,
                                                 boolean lastFragmentOfMessage)
                                          throws IOException
        Description copied from interface: ExtensionFunction
        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
        Specified by:
        transformForRead in interface ExtensionFunction
        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