Package io.fluxcapacitor.javaclient.web
Class WebsocketResponseInterceptor
java.lang.Object
io.fluxcapacitor.javaclient.web.WebsocketResponseInterceptor
- All Implemented Interfaces:
DispatchInterceptor
A
DispatchInterceptor
that modifies outgoing WebResponse
messages in response to WebSocket-based
WebRequest
s.
This interceptor ensures that appropriate metadata is included in the corresponding WebResponse
. It supports
both the WebSocket handshake phase and subsequent message exchanges over an established WebSocket session.
Specifically:
- If the incoming message is a
WS_HANDSHAKE
, it adds theclientId
andtrackerId
to the response metadata to identify the connection. - If the session is already open, it includes the
sessionId
and, if absent, sets afunction
field to eithermessage
orack
, depending on whether the outgoing message has a payload.
This ensures that the Flux WebSocket infrastructure can properly route and interpret messages sent back to the client.
-
Field Summary
Fields inherited from interface io.fluxcapacitor.javaclient.publishing.DispatchInterceptor
noOp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninterceptDispatch
(Message message, MessageType messageType, String topic) Intercepts and conditionally modifies an outgoing message in the context of a WebSocket request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.publishing.DispatchInterceptor
andThen, modifySerializedMessage, monitorDispatch
-
Constructor Details
-
WebsocketResponseInterceptor
public WebsocketResponseInterceptor()
-
-
Method Details
-
interceptDispatch
Intercepts and conditionally modifies an outgoing message in the context of a WebSocket request.- Specified by:
interceptDispatch
in interfaceDispatchInterceptor
- Parameters:
message
- the original message to be dispatchedmessageType
- the type of the message (e.g., WEBRESPONSE)topic
- the topic to which the message is being published- Returns:
- the possibly modified message
-