Class WebsocketResponseInterceptor

java.lang.Object
io.fluxcapacitor.javaclient.web.WebsocketResponseInterceptor
All Implemented Interfaces:
DispatchInterceptor

public class WebsocketResponseInterceptor extends Object implements DispatchInterceptor
A DispatchInterceptor that modifies outgoing WebResponse messages in response to WebSocket-based WebRequests.

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 the clientId and trackerId to the response metadata to identify the connection.
  • If the session is already open, it includes the sessionId and, if absent, sets a function field to either message or ack, 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.

  • Constructor Details

    • WebsocketResponseInterceptor

      public WebsocketResponseInterceptor()
  • Method Details

    • interceptDispatch

      public Message interceptDispatch(Message message, MessageType messageType, String topic)
      Intercepts and conditionally modifies an outgoing message in the context of a WebSocket request.
      Specified by:
      interceptDispatch in interface DispatchInterceptor
      Parameters:
      message - the original message to be dispatched
      messageType - the type of the message (e.g., WEBRESPONSE)
      topic - the topic to which the message is being published
      Returns:
      the possibly modified message