Class DeflateEncoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageEncoder<WebSocketFrame>
-
- io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionEncoder
-
- io.netty.handler.codec.http.websocketx.extensions.compression.DeflateEncoder
-
- All Implemented Interfaces:
ChannelHandler,ChannelOutboundHandler
- Direct Known Subclasses:
PerFrameDeflateEncoder,PerMessageDeflateEncoder
abstract class DeflateEncoder extends WebSocketExtensionEncoder
Deflate implementation of a payload compressor for io.netty.handler.codec.http.websocketx.WebSocketFrame.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private intcompressionLevelprivate EmbeddedChannelencoderprivate WebSocketExtensionFilterextensionEncoderFilterprivate booleannoContextprivate intwindowSize
-
Constructor Summary
Constructors Constructor Description DeflateEncoder(int compressionLevel, int windowSize, boolean noContext, WebSocketExtensionFilter extensionEncoderFilter)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidcleanup()private ByteBufcompressContent(ChannelHandlerContext ctx, WebSocketFrame msg)protected voidencode(ChannelHandlerContext ctx, WebSocketFrame msg, java.util.List<java.lang.Object> out)Encode from one message to an other.protected WebSocketExtensionFilterextensionEncoderFilter()Returns the extension encoder filter.voidhandlerRemoved(ChannelHandlerContext ctx)Do nothing by default, sub-classes may override this method.protected abstract booleanremoveFrameTail(WebSocketFrame msg)protected abstract intrsv(WebSocketFrame msg)-
Methods inherited from class io.netty.handler.codec.MessageToMessageEncoder
acceptOutboundMessage, write
-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, read
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
exceptionCaught, handlerAdded
-
-
-
-
Field Detail
-
compressionLevel
private final int compressionLevel
-
windowSize
private final int windowSize
-
noContext
private final boolean noContext
-
extensionEncoderFilter
private final WebSocketExtensionFilter extensionEncoderFilter
-
encoder
private EmbeddedChannel encoder
-
-
Constructor Detail
-
DeflateEncoder
DeflateEncoder(int compressionLevel, int windowSize, boolean noContext, WebSocketExtensionFilter extensionEncoderFilter)Constructor- Parameters:
compressionLevel- compression level of the compressor.windowSize- maximum size of the window compressor buffer.noContext- true to disable context takeover.extensionEncoderFilter- extension encoder filter.
-
-
Method Detail
-
extensionEncoderFilter
protected WebSocketExtensionFilter extensionEncoderFilter()
Returns the extension encoder filter.
-
rsv
protected abstract int rsv(WebSocketFrame msg)
- Parameters:
msg- the current frame.- Returns:
- the rsv bits to set in the compressed frame.
-
removeFrameTail
protected abstract boolean removeFrameTail(WebSocketFrame msg)
- Parameters:
msg- the current frame.- Returns:
- true if compressed payload tail needs to be removed.
-
encode
protected void encode(ChannelHandlerContext ctx, WebSocketFrame msg, java.util.List<java.lang.Object> out) throws java.lang.Exception
Description copied from class:MessageToMessageEncoderEncode from one message to an other. This method will be called for each written message that can be handled by this encoder.- Specified by:
encodein classMessageToMessageEncoder<WebSocketFrame>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToMessageEncoderbelongs tomsg- the message to encode to an other oneout- theListinto which the encoded msg should be added needs to do some kind of aggregation- Throws:
java.lang.Exception- is thrown if an error occurs
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerRemovedin interfaceChannelHandler- Overrides:
handlerRemovedin classChannelHandlerAdapter- Throws:
java.lang.Exception
-
compressContent
private ByteBuf compressContent(ChannelHandlerContext ctx, WebSocketFrame msg)
-
cleanup
private void cleanup()
-
-