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
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Dispose this function.boolean
Validate if current extension defines a new WebSocket Opcode.transformForRead
(PooledByteBuffer pooledBuffer, StreamSourceFrameChannel channel, boolean lastFragmentOfMessage) Transform the supplied buffer per this extension.transformForWrite
(PooledByteBuffer pooledBuffer, StreamSinkFrameChannel channel, boolean lastFrame) Transform the supplied buffer per this extension.int
writeRsv
(int rsv) Add RSV bits (RSV1, RSV2, RSV3) to the current rsv status.
-
Field Details
-
RSV1
static final int RSV1Bitmask for RSV1 bit used in extensions.- See Also:
-
RSV2
static final int RSV2Bitmask for RSV2 bit used in extensions.- See Also:
-
RSV3
static final int RSV3Bitmask for RSV3 bit used in extensions.- See Also:
-
-
Method Details
-
hasExtensionOpCode
boolean hasExtensionOpCode()Validate if current extension defines a new WebSocket Opcode.- Returns:
true
if current extension defines specific Opcodefalse
is current extension does not define specific Opcode- See Also:
-
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 transformchannel
- 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 transformchannel
- working channellastFragmentOfMessage
- 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
-