Top Description Fields Constructors Methods
io.undertow.websockets.extensions

public Class PerMessageDeflateFunction

extends Object
implements ExtensionFunction
Class Inheritance
All Implemented Interfaces
io.undertow.websockets.extensions.ExtensionFunction
Imports
io.undertow.connector.ByteBufferPool, .PooledByteBuffer, io.undertow.util.ImmediatePooledByteBuffer, io.undertow.websockets.core.StreamSinkFrameChannel, .StreamSourceFrameChannel, .WebSocketChannel, .WebSocketLogger, .WebSocketMessages, org.xnio.Buffers, .IoUtils, java.io.IOException, java.nio.ByteBuffer, java.util.zip.DataFormatException, .Deflater, .Inflater

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

Field Summary

Modifier and TypeField and Description
private final Deflater
private final boolean
private StreamSourceFrameChannel
private final Inflater
private final boolean
private final int
private static final byte[]

Constructor Summary

AccessConstructor and Description
public
PerMessageDeflateFunction(final int
the level of configuration of DEFLATE algorithm implementation
deflaterLevel
,
boolean
flag for compressor context takeover or without compressor context
compressContextTakeover
,
boolean
flag for decompressor context takeover or without decompressor context
decompressContextTakeover
)

Create a new PerMessageDeflateExtension instance.

Method Summary

Modifier and TypeMethod and Description
private PooledByteBuffer
private PooledByteBuffer
public void
public boolean
hasExtensionOpCode()

Implements io.undertow.websockets.extensions.ExtensionFunction.hasExtensionOpCode.

Validate if current extension defines a new WebSocket Opcode.

private PooledByteBuffer
largerBuffer(PooledByteBuffer smaller, WebSocketChannel channel, int newSize)

private PooledByteBuffer
public synchronized PooledByteBuffer
transformForRead(PooledByteBuffer
Buffer to transform
pooledBuffer
,
StreamSourceFrameChannel
working channel
channel
,
boolean
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
lastFragmentOfMessage
)

Implements io.undertow.websockets.extensions.ExtensionFunction.transformForRead.

Transform the supplied buffer per this extension.

public synchronized PooledByteBuffer
transformForWrite(PooledByteBuffer
Buffer to transform
pooledBuffer
,
StreamSinkFrameChannel
working channel
channel
,
boolean lastFrame)

Implements io.undertow.websockets.extensions.ExtensionFunction.transformForWrite.

Transform the supplied buffer per this extension.

public int
writeRsv(int
current RSV bits status
rsv
)

Implements io.undertow.websockets.extensions.ExtensionFunction.writeRsv.

Add RSV bits (RSV1, RSV2, RSV3) to the current rsv status.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compressback to summary
private final Deflater compress
compressContextTakeoverback to summary
private final boolean compressContextTakeover
currentReadChannelback to summary
private StreamSourceFrameChannel currentReadChannel
decompressback to summary
private final Inflater decompress
decompressContextTakeoverback to summary
private final boolean decompressContextTakeover
deflaterLevelback to summary
private final int deflaterLevel
TAILback to summary
private static final byte[] TAIL

Constructor Detail

PerMessageDeflateFunctionback to summary
public PerMessageDeflateFunction(final int deflaterLevel, boolean compressContextTakeover, boolean decompressContextTakeover)

Create a new PerMessageDeflateExtension instance.

Parameters
deflaterLevel:int

the level of configuration of DEFLATE algorithm implementation

compressContextTakeover:boolean

flag for compressor context takeover or without compressor context

decompressContextTakeover:boolean

flag for decompressor context takeover or without decompressor context

Method Detail

allocateBufferWithArrayback to summary
private PooledByteBuffer allocateBufferWithArray(WebSocketChannel channel, int size)
decompressback to summary
private PooledByteBuffer decompress(WebSocketChannel channel, PooledByteBuffer pooled) throws IOException
disposeback to summary
public void dispose()

Implements io.undertow.websockets.extensions.ExtensionFunction.dispose.

Doc from io.undertow.websockets.extensions.ExtensionFunction.dispose.

Dispose this function. Called upon connection closure

Annotations
@Override
hasExtensionOpCodeback to summary
public boolean hasExtensionOpCode()

Implements io.undertow.websockets.extensions.ExtensionFunction.hasExtensionOpCode.

Doc from io.undertow.websockets.extensions.ExtensionFunction.hasExtensionOpCode.

Validate if current extension defines a new WebSocket Opcode.

Returns:boolean

true if current extension defines specific Opcode false is current extension does not define specific Opcode

Annotations
@Override
largerBufferback to summary
private PooledByteBuffer largerBuffer(PooledByteBuffer smaller, WebSocketChannel channel, int newSize)
toArrayBackedback to summary
private PooledByteBuffer toArrayBacked(ByteBuffer buffer, ByteBufferPool pool)
transformForReadback to summary
public synchronized PooledByteBuffer transformForRead(PooledByteBuffer pooledBuffer, StreamSourceFrameChannel channel, boolean lastFragmentOfMessage) throws IOException

Implements io.undertow.websockets.extensions.ExtensionFunction.transformForRead.

Doc from io.undertow.websockets.extensions.ExtensionFunction.transformForRead.

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:PooledByteBuffer

Buffer to transform

channel:StreamSourceFrameChannel

working channel

lastFragmentOfMessage:boolean

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:PooledByteBuffer

transformed buffer (may be the same one, just with modified contents)

Annotations
@Override
transformForWriteback to summary
public synchronized PooledByteBuffer transformForWrite(PooledByteBuffer pooledBuffer, StreamSinkFrameChannel channel, boolean lastFrame) throws IOException

Implements io.undertow.websockets.extensions.ExtensionFunction.transformForWrite.

Doc from io.undertow.websockets.extensions.ExtensionFunction.transformForWrite.

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:PooledByteBuffer

Buffer to transform

channel:StreamSinkFrameChannel

working channel

Returns:PooledByteBuffer

transformed buffer (may be the same one, just with modified contents)

Annotations
@Override
writeRsvback to summary
public int writeRsv(int rsv)

Implements io.undertow.websockets.extensions.ExtensionFunction.writeRsv.

Doc from io.undertow.websockets.extensions.ExtensionFunction.writeRsv.

Add RSV bits (RSV1, RSV2, RSV3) to the current rsv status.

Parameters
rsv:int

current RSV bits status

Returns:int

rsv status

Annotations
@Override