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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
dispose()
Dispose this function.boolean
hasExtensionOpCode()
Validate if current extension defines a new WebSocket Opcode.PooledByteBuffer
transformForRead(PooledByteBuffer pooledBuffer, StreamSourceFrameChannel channel, boolean lastFragmentOfMessage)
Transform the supplied buffer per this extension.PooledByteBuffer
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 Detail
-
RSV1
static final int RSV1
Bitmask for RSV1 bit used in extensions.- See Also:
- Constant Field Values
-
RSV2
static final int RSV2
Bitmask for RSV2 bit used in extensions.- See Also:
- Constant Field Values
-
RSV3
static final int RSV3
Bitmask for RSV3 bit used in extensions.- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
- WebSocket Base Framing Protocol Reference
-
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 java.io.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:
java.io.IOException
-
transformForRead
PooledByteBuffer transformForRead(PooledByteBuffer pooledBuffer, StreamSourceFrameChannel channel, boolean lastFragmentOfMessage) throws java.io.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:
java.io.IOException
-
dispose
void dispose()
Dispose this function. Called upon connection closure
-
-