Top Description Fields Constructors Methods
org.java_websocket.extensions.permessage_deflate

public Class PerMessageDeflateExtension

extends CompressionExtension
Class Inheritance
Imports
java.io.ByteArrayOutputStream, java.nio.ByteBuffer, java.util.LinkedHashMap, .Map, java.util.zip.DataFormatException, .Deflater, .Inflater, org.java_websocket.enums.Opcode, org.java_websocket.exceptions.InvalidDataException, .InvalidFrameException, org.java_websocket.extensions.CompressionExtension, .ExtensionRequestData, .IExtension, org.java_websocket.framing.CloseFrame, .ContinuousFrame, .DataFrame, .Framedata, .FramedataImpl1

PerMessage Deflate Extension (7. The "permessage-deflate" Extension in RFC 7692).
See Also
7. The "permessage-deflate" Extension in RFC 7692

Field Summary

Modifier and TypeField and Description
private static final int
private static final String
private static final String
private static final int
private boolean
private final int
private final Deflater
private static final String
private final Inflater
private Map<String, String>
private static final String
private static final String
private static final int
private boolean
private static final byte[]
private int

Constructor Summary

AccessConstructor and Description
public
PerMessageDeflateExtension()

Constructor for the PerMessage Deflate Extension (7. Thepermessage-deflate" Extension) Uses java.util.zip.Deflater#DEFAULT_COMPRESSION as the compression level for the java.util.zip.Deflater#Deflater(int)

public
PerMessageDeflateExtension(int
The compression level passed to the java.util.zip.Deflater#Deflater(int)
compressionLevel
)

Constructor for the PerMessage Deflate Extension (7. Thepermessage-deflate" Extension)

Method Summary

Modifier and TypeMethod and Description
public boolean
acceptProvidedExtensionAsClient(String inputExtension)

Overrides org.java_websocket.extensions.DefaultExtension.acceptProvidedExtensionAsClient.

Implements org.java_websocket.extensions.IExtension.acceptProvidedExtensionAsClient.

Check if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a client

public boolean
acceptProvidedExtensionAsServer(String inputExtension)

Overrides org.java_websocket.extensions.DefaultExtension.acceptProvidedExtensionAsServer.

Implements org.java_websocket.extensions.IExtension.acceptProvidedExtensionAsServer.

Check if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a server

public IExtension
public void
decodeFrame(Framedata inputFrame)

Overrides org.java_websocket.extensions.DefaultExtension.decodeFrame.

Implements org.java_websocket.extensions.IExtension.decodeFrame.

Decode a frame with a extension specific algorithm.

private void
decompress(byte[]
the bytes of data
data
,
ByteArrayOutputStream
the output stream
outputBuffer
)

public void
encodeFrame(Framedata inputFrame)

Overrides org.java_websocket.extensions.DefaultExtension.encodeFrame.

Implements org.java_websocket.extensions.IExtension.encodeFrame.

Encode a frame with a extension specific algorithm.

private static boolean

Returns:

true if the data is OK
endsWithTail
(byte[]
the bytes of data
data
)

public int

Returns:

the compression level
getCompressionLevel
()

Get the compression level used for the compressor.

public String
getProvidedExtensionAsClient()

Overrides org.java_websocket.extensions.DefaultExtension.getProvidedExtensionAsClient.

Implements org.java_websocket.extensions.IExtension.getProvidedExtensionAsClient.

Return the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a client.

public String
getProvidedExtensionAsServer()

Overrides org.java_websocket.extensions.DefaultExtension.getProvidedExtensionAsServer.

Implements org.java_websocket.extensions.IExtension.getProvidedExtensionAsServer.

Return the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a server.

public int

Returns:

Size (in bytes) below which messages will not be compressed
getThreshold
()

Get the size threshold for doing the compression

public boolean

Returns:

clientNoContextTakeover is the client no context parameter active
isClientNoContextTakeover
()

Access the "client_no_context_takeover" extension parameter

public void
isFrameValid(Framedata inputFrame)

Overrides org.java_websocket.extensions.CompressionExtension.isFrameValid.

Implements org.java_websocket.extensions.IExtension.isFrameValid.

This extension requires the RSV1 bit to be set only for the first frame.

public boolean

Returns:

serverNoContextTakeover is the server no context parameter active
isServerNoContextTakeover
()

Access the "server_no_context_takeover" extension parameter

public void
setClientNoContextTakeover(boolean
set the client no context parameter
clientNoContextTakeover
)

Setter for the "client_no_context_takeover" extension parameter

public void
setServerNoContextTakeover(boolean
set the server no context parameter
serverNoContextTakeover
)

Setter for the "server_no_context_takeover" extension parameter

public void
setThreshold(int
the size in bytes
threshold
)

Set the size when payloads smaller than this will not be compressed.

public String
toString()

Overrides org.java_websocket.extensions.DefaultExtension.toString.

Implements org.java_websocket.extensions.IExtension.toString.

Return a string which should contain the class name as well as additional information about the current configurations for this extension (DEBUG purposes)

Field Detail

BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
CLIENT_MAX_WINDOW_BITSback to summary
private static final String CLIENT_MAX_WINDOW_BITS
CLIENT_NO_CONTEXT_TAKEOVERback to summary
private static final String CLIENT_NO_CONTEXT_TAKEOVER
clientMaxWindowBitsback to summary
private static final int clientMaxWindowBits
clientNoContextTakeoverback to summary
private boolean clientNoContextTakeover
compressionLevelback to summary
private final int compressionLevel
deflaterback to summary
private final Deflater deflater
EXTENSION_REGISTERED_NAMEback to summary
private static final String EXTENSION_REGISTERED_NAME
inflaterback to summary
private final Inflater inflater
requestedParametersback to summary
private Map<String, String> requestedParameters
SERVER_MAX_WINDOW_BITSback to summary
private static final String SERVER_MAX_WINDOW_BITS
SERVER_NO_CONTEXT_TAKEOVERback to summary
private static final String SERVER_NO_CONTEXT_TAKEOVER
serverMaxWindowBitsback to summary
private static final int serverMaxWindowBits
serverNoContextTakeoverback to summary
private boolean serverNoContextTakeover
TAIL_BYTESback to summary
private static final byte[] TAIL_BYTES
thresholdback to summary
private int threshold

Constructor Detail

PerMessageDeflateExtensionback to summary
public PerMessageDeflateExtension()

Constructor for the PerMessage Deflate Extension (7. Thepermessage-deflate" Extension) Uses java.util.zip.Deflater#DEFAULT_COMPRESSION as the compression level for the java.util.zip.Deflater#Deflater(int)

PerMessageDeflateExtensionback to summary
public PerMessageDeflateExtension(int compressionLevel)

Constructor for the PerMessage Deflate Extension (7. Thepermessage-deflate" Extension)

Parameters
compressionLevel:int

The compression level passed to the java.util.zip.Deflater#Deflater(int)

Method Detail

acceptProvidedExtensionAsClientback to summary
public boolean acceptProvidedExtensionAsClient(String inputExtension)

Overrides org.java_websocket.extensions.DefaultExtension.acceptProvidedExtensionAsClient.

Implements org.java_websocket.extensions.IExtension.acceptProvidedExtensionAsClient.

Doc from org.java_websocket.extensions.IExtension.acceptProvidedExtensionAsClient.

Check if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a client

Annotations
@Override
acceptProvidedExtensionAsServerback to summary
public boolean acceptProvidedExtensionAsServer(String inputExtension)

Overrides org.java_websocket.extensions.DefaultExtension.acceptProvidedExtensionAsServer.

Implements org.java_websocket.extensions.IExtension.acceptProvidedExtensionAsServer.

Doc from org.java_websocket.extensions.IExtension.acceptProvidedExtensionAsServer.

Check if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a server

Annotations
@Override
copyInstanceback to summary
public IExtension copyInstance()

Overrides org.java_websocket.extensions.DefaultExtension.copyInstance.

Implements org.java_websocket.extensions.IExtension.copyInstance.

Doc from org.java_websocket.extensions.IExtension.copyInstance.

Extensions must only be by one websocket at all. To prevent extensions to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given extension instance.
The copy can be safely used in conjunction with a new websocket connection.

Annotations
@Override
decodeFrameback to summary
public void decodeFrame(Framedata inputFrame) throws InvalidDataException

Overrides org.java_websocket.extensions.DefaultExtension.decodeFrame.

Implements org.java_websocket.extensions.IExtension.decodeFrame.

Doc from org.java_websocket.extensions.IExtension.decodeFrame.

Decode a frame with a extension specific algorithm. The algorithm is subject to be implemented by the specific extension. The resulting frame will be used in the application

Annotations
@Override
Exceptions
InvalidDataException:
Throw InvalidDataException if the received frame is not correctly implemented by the other endpoint or there are other protocol errors/decoding errors
decompressback to summary
private void decompress(byte[] data, ByteArrayOutputStream outputBuffer) throws DataFormatException
Parameters
data:byte[]

the bytes of data

outputBuffer:ByteArrayOutputStream

the output stream

encodeFrameback to summary
public void encodeFrame(Framedata inputFrame)

Overrides org.java_websocket.extensions.DefaultExtension.encodeFrame.

Implements org.java_websocket.extensions.IExtension.encodeFrame.

Doc from org.java_websocket.extensions.IExtension.encodeFrame.

Encode a frame with a extension specific algorithm. The algorithm is subject to be implemented by the specific extension. The resulting frame will be send to the other endpoint.

Annotations
@Override
endsWithTailback to summary
private static boolean endsWithTail(byte[] data)
Parameters
data:byte[]

the bytes of data

Returns:boolean

true if the data is OK

getCompressionLevelback to summary
public int getCompressionLevel()

Get the compression level used for the compressor.

Returns:int

the compression level

getProvidedExtensionAsClientback to summary
public String getProvidedExtensionAsClient()

Overrides org.java_websocket.extensions.DefaultExtension.getProvidedExtensionAsClient.

Implements org.java_websocket.extensions.IExtension.getProvidedExtensionAsClient.

Doc from org.java_websocket.extensions.IExtension.getProvidedExtensionAsClient.

Return the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a client. If the extension returns an empty string (""), the offer will not be included in the handshake.

Annotations
@Override
getProvidedExtensionAsServerback to summary
public String getProvidedExtensionAsServer()

Overrides org.java_websocket.extensions.DefaultExtension.getProvidedExtensionAsServer.

Implements org.java_websocket.extensions.IExtension.getProvidedExtensionAsServer.

Doc from org.java_websocket.extensions.IExtension.getProvidedExtensionAsServer.

Return the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a server. If the extension returns an empty string (""), the offer will not be included in the handshake.

Annotations
@Override
getThresholdback to summary
public int getThreshold()

Get the size threshold for doing the compression

Returns:int

Size (in bytes) below which messages will not be compressed

Since
1.5.3
isClientNoContextTakeoverback to summary
public boolean isClientNoContextTakeover()

Access the "client_no_context_takeover" extension parameter

Returns:boolean

clientNoContextTakeover is the client no context parameter active

See Also
The "client_no_context_takeover" Extension Parameter
isFrameValidback to summary
public void isFrameValid(Framedata inputFrame) throws InvalidDataException

Overrides org.java_websocket.extensions.CompressionExtension.isFrameValid.

Implements org.java_websocket.extensions.IExtension.isFrameValid.

This extension requires the RSV1 bit to be set only for the first frame. If the frame is type is CONTINUOUS, RSV1 bit must be unset.

Annotations
@Override
Exceptions
InvalidDataException:

Doc from org.java_websocket.extensions.IExtension.isFrameValid.

Throw InvalidDataException if the received frame is not correctly implementing the specification for the specific extension

isServerNoContextTakeoverback to summary
public boolean isServerNoContextTakeover()

Access the "server_no_context_takeover" extension parameter

Returns:boolean

serverNoContextTakeover is the server no context parameter active

See Also
The "server_no_context_takeover" Extension Parameter
setClientNoContextTakeoverback to summary
public void setClientNoContextTakeover(boolean clientNoContextTakeover)

Setter for the "client_no_context_takeover" extension parameter

Parameters
clientNoContextTakeover:boolean

set the client no context parameter

See Also
The "client_no_context_takeover" Extension Parameter
setServerNoContextTakeoverback to summary
public void setServerNoContextTakeover(boolean serverNoContextTakeover)

Setter for the "server_no_context_takeover" extension parameter

Parameters
serverNoContextTakeover:boolean

set the server no context parameter

See Also
The "server_no_context_takeover" Extension Parameter
setThresholdback to summary
public void setThreshold(int threshold)

Set the size when payloads smaller than this will not be compressed.

Parameters
threshold:int

the size in bytes

Since
1.5.3
toStringback to summary
public String toString()

Overrides org.java_websocket.extensions.DefaultExtension.toString.

Implements org.java_websocket.extensions.IExtension.toString.

Doc from org.java_websocket.extensions.IExtension.toString.

Return a string which should contain the class name as well as additional information about the current configurations for this extension (DEBUG purposes)

Annotations
@Override