Class WebSocketExtension
java.lang.Object
de.craftsblock.craftsnet.api.websocket.extensions.WebSocketExtension
- Direct Known Subclasses:
PerMessageDeflateExtension
Abstract base class for WebSocket extensions. A WebSocket extension allows for
custom encoding and decoding of WebSocket frames to support features such as
compression, encryption, or other protocol enhancements.
Each extension has a protocol name that identifies it. Subclasses must implement
the encode(Frame) and decode(Frame) methods to define how frames
are transformed by the extension.
- Since:
- 3.0.6-SNAPSHOT
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketExtension(String protocolName) Constructs a new WebSocket extension with the specified protocol name. -
Method Summary
-
Constructor Details
-
WebSocketExtension
Constructs a new WebSocket extension with the specified protocol name.- Parameters:
protocolName- the name of the protocol for this extension. This name is used to identify the extension during the WebSocket handshake and negotiation process.
-
-
Method Details
-
encode
Encodes a WebSocket frame according to the rules of this extension. This method is called before the frame is sent over the network.- Parameters:
frame- the frame to be encoded. The frame should not be null.- Returns:
- the encoded frame. The result should not be null.
-
decode
Decodes a WebSocket frame according to the rules of this extension. This method is called after the frame is received from the network.- Parameters:
frame- the frame to be decoded. The frame should not be null.- Returns:
- the decoded frame. The result should not be null.
-
getProtocolName
Returns the protocol name of this extension.- Returns:
- the protocol name. This value is used to identify the extension.
-