Interface WebSocketExchangeHandler<A extends ExchangeContext,B extends WebSocketExchange<A>>

Type Parameters:
A - the type of the exchange context
B - the type of WebSocket exchange handled by the handler
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface WebSocketExchangeHandler<A extends ExchangeContext,B extends WebSocketExchange<A>>

A WebSocket exchange handler is used to handle WebSocket exchange.

It allows to specify the behaviour of the server when a WebSocket connection has been established between a client and the server.

Since:
1.5
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    default Mono<Void>
    defer(B webSocketExchange)
    Returns a Mono that defers the processing of the WebSocket exchange.
    void
    handle(B webSocketExchange)
    Processes the specified WebSocket server exchange.
  • Method Details

    • defer

      default Mono<Void> defer(B webSocketExchange) throws WebSocketException

      Returns a Mono that defers the processing of the WebSocket exchange.

      The server subscribes to the returned Mono and after completion, emits received messages in the inbound frames stream and subscribes to the exchange outbound frames stream to send WebSocket frames to the client.

      By default, returns a Mono that defers the execution of handle(io.inverno.mod.http.server.ws.WebSocketExchange).

      Parameters:
      webSocketExchange - the WebSocket exchange to process
      Returns:
      an empty mono that completes when the WebSocket exchange has been processed
      Throws:
      WebSocketException - if an error occurs during the processing of the exchange
    • handle

      void handle(B webSocketExchange) throws WebSocketException

      Processes the specified WebSocket server exchange.

      This method is more convenient than defer(io.inverno.mod.http.server.ws.WebSocketExchange) when the handling logic does not need to be reactive.

      Parameters:
      webSocketExchange - the WebSocket exchange to process
      Throws:
      WebSocketException - if an error occurs during the processing of the exchange