Extension.
Capable of parameters negotiation, incoming and outgoing frames processing.
Extensions are ordered as they appear in handshake response headers, as per RFC 6455, chapter 9.1. It does not state any ordering in regards of sender/receiver side and current implementation reflects that. See TODO below for possible issue related to ordering.
Let's say we have negotiated two extensions, ext1 and ext2 in this order without parameters, so handshake response headers will be: "sec-websocket-extensions: ext1, ext2". Prefix "c_" means client side, prefix "s_" server side.
client -> server
+--------+ +--------+ +--------+ +--------+
client >----| c_ext1 |-->| c_ext2 |--> [network] --> | s_ext1 |-->| s_ext2 |--> server
+--------+ +--------+ +--------+ +--------+
client <- server
+--------+ +--------+ +--------+ +--------+
client <----| c_ext2 |<--| c_ext1 |<-- [network] <-- | s_ext2 |<--| s_ext1 |<-- server
+--------+ +--------+ +--------+ +--------+
Any exception thrown from processIncoming or processOutgoing will be logged. Rest of extension chain will be invoked
without any modifications done in "faulty" extension. jakarta. won't be triggered. (this
might
change).
TODO:\ - naming. - ordering - we might need to ensure that compression/decompression is invoked first when receiving and last when sending message (to enable access to uncompressed data for other extensions). - param negotiation. - param validation. - general validation - two extensions using same rsv bit cannot be "negotiated" for same session/connection. - negotiation exception handling (onExtensionNegotiation)
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ExtendedExtension.
Context present as a parameter in all |
| Modifier and Type | Method and Description |
|---|---|
| public void | destroy(ExtendedExtension.
extension context to be destroyed. contextContext lifecycle method. |
| public List | Returns: parameters to be present in handshake response.extension context. context,requested parameters (from handshake request). requestedParametersParameter negotiation. |
| public void | onHandshakeResponse(ExtendedExtension.
extension context. context,extension parameters returned from the server. responseParametersCalled only on the client side when handshake response arrives. |
| public Frame | Returns: processed frame. Can be new instance.per-connection/session context. context,websocket frame representation. frame)Process incoming frame. |
| public Frame | Returns: processed frame. Can be new instance.per-connection/session context. context,websocket frame representation. frame)Process outgoing frame. |
| destroy | back to summary |
|---|---|
| public void destroy(ExtendedExtension. Context lifecycle method.
| |
| onExtensionNegotiation | back to summary |
|---|---|
| public List Parameter negotiation. Executed before handshake response is sent to the client (server only). Returned list of parameters will be present in handshake response headers. Todo Seems like list of all "requested" extensions should be passed (at least all with the same name) - the Todo extension implementation should be able to choose which version (parameter set) will be used for the TODO: established WebSocket session. (We should also properly describe that this method will be called only once TODO: per extension per websocket session and have the possibility to NOT add this extension to negotiated TODO: extensions).
| |
| onHandshakeResponse | back to summary |
|---|---|
| public void onHandshakeResponse(ExtendedExtension. Called only on the client side when handshake response arrives. Can be used to process extension parameters returned from server side.
| |
| processIncoming | back to summary |
|---|---|
| public Frame processIncoming(ExtendedExtension. Process incoming frame. Passed frame is unmasked in case it was masked when received (server to client communication).
| |
| processOutgoing | back to summary |
|---|---|
| public Frame processOutgoing(ExtendedExtension. Process outgoing frame. Passed frame is unmasked. Frame payload will be masked when required (server to client communication).
| |
ExtendedExtension methods. Maintains per
connection state of current extension.
Context is created right before onExtensionNegotiation(ExtendedExtension. method call (server-side) or onHandshakeResponse(ExtendedExtension. method call (client-side). Last chance to access it is within destroy(ExtendedExtension. method invocation.
| getProperties | back to summary |
|---|---|
| public Map Mutable, not synchronised property map.
Synchronisation is not necessary if you are accessing this map only during | |