Interface WebsocketMiddleware

All Superinterfaces:
Middleware

public interface WebsocketMiddleware extends Middleware
A specific middleware for manipulating websocket clients connections.
Since:
3.4.0-SNAPSHOT
See Also:
  • Method Details

    • handleConnect

      default void handleConnect(MiddlewareCallbackInfo callbackInfo, SocketExchange exchange)
      Defines middleware logic when a new websocket client connects to the server.

      Note: The middleware logic is applied after the ClientConnectEvent and before the actual endpoint mapping logic of the websocket client.

      Parameters:
      callbackInfo - The callback info that is used to store data between middlewares.
      exchange - The exchange holding the data of the websocket session.
    • handleDisconnect

      default void handleDisconnect(MiddlewareCallbackInfo callbackInfo, SocketExchange exchange)
      Defines middleware logic when a new websocket client disconnects from the server.

      Note: The middleware logic is applied after the ClientDisconnectEvent and before the actual disconnect logic of the websocket client. Therefore that the websocket session is definitely going to be terminated the MiddlewareCallbackInfo.setCancelled(boolean) statement will be ignored.

      Parameters:
      callbackInfo - The callback info that is used to store data between middlewares.
      exchange - The exchange holding the data of the websocket session.
    • handleMessageReceived

      default void handleMessageReceived(MiddlewareCallbackInfo callbackInfo, SocketExchange exchange, Frame frame)
      Defines middleware logic when the server received a new message from the websocket client.

      Note: The middleware logic is applied after the IncomingSocketMessageEvent and before the actual endpoint message handling logic of the websocket client.

      Parameters:
      callbackInfo - The callback info that is used to store data between middlewares.
      exchange - The exchange holding the data of the websocket session.
      frame - The frame which was received.
    • handleMessageSent

      default void handleMessageSent(MiddlewareCallbackInfo callbackInfo, SocketExchange exchange, Frame frame)
      Defines middleware logic when the server sends a new message to the websocket client.

      Note: The middleware logic is applied after the OutgoingSocketMessageEvent and before the actual message sending of the websocket client.

      Parameters:
      callbackInfo - The callback info that is used to store data between middlewares.
      exchange - The exchange holding the data of the websocket session.
      frame - The frame which was sent.
    • handle

      default void handle(MiddlewareCallbackInfo callbackInfo, BaseExchange exchange)
      Defines the logic of the middleware.
      Specified by:
      handle in interface Middleware
      Parameters:
      callbackInfo - The callback info that is used to store data between middlewares.
      exchange - The exchange that holds the data of the request.
    • isApplicable

      default boolean isApplicable(Class<? extends Server> server)
      Checks if the middleware is applicable of handling the specific servers exchange.

      This implementation checks if the server is a websocket server.

      Specified by:
      isApplicable in interface Middleware
      Parameters:
      server - The server to check.
      Returns:
      true if the middleware can handle the server, false otherwise.