Class WebsocketHandlerDecorator

java.lang.Object
io.fluxcapacitor.javaclient.web.WebsocketHandlerDecorator
All Implemented Interfaces:
ParameterResolver<HasMessage>, HandlerDecorator

public class WebsocketHandlerDecorator extends Object implements HandlerDecorator, ParameterResolver<HasMessage>
Decorator that adds WebSocket session support to handler classes and enables parameter injection for SocketSession.

This decorator supports @HandleWeb-annotated methods that interact over WebSocket connections, and transparently manages the lifecycle of SocketSession instances. It implements both HandlerDecorator and ParameterResolver to provide the following capabilities:

  • Automatically upgrades incoming WS_HANDSHAKE requests to WebSocket sessions if the handler includes methods annotated with HandleSocketOpen or similar, but does not explicitly handle the handshake itself. This ensures that endpoints which declare websocket handlers still result in a successful connection upgrade even without a dedicated handshake method.
  • Delegates WS_MESSAGE requests to the associated SocketSession for message dispatch and response.
  • Performs cleanup on WS_CLOSE requests, closing the session and invoking any associated HandleSocketClose handlers.
  • Resolves SocketSession method parameters in applicable WebSocket handler methods.

This decorator also tracks open WebSocket sessions and ensures that message dispatch is session-aware. It works transparently with the Flux client’s message routing and tracking infrastructure.