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

Type Parameters:
A - the type of the exchange context
B - the type of WebSocket exchange

public interface WebSocket<A extends ExchangeContext,B extends WebSocketExchange<A>>

A server-side WebSocket.

A WebSocket is created by upgrading to the WebSocket protocol using Exchange.webSocket(java.lang.String...). It is used to specify the WebSocketExchangeHandler which handles the WebSocketExchange once the opening handshake has been completed.

A fallback action can also be specified which is executed if the opening handshake failed.

Since:
1.5
Author:
Jeremy Kuhn
  • Method Summary

    Modifier and Type
    Method
    Description
    handler(WebSocketExchangeHandler<? super A,B> handler)
    Specifies the handler used to handle the WebSocket exchange.
    default WebSocket<A,B>
    or(Runnable fallback)
    Specifies the fallback action to execute when the opening handshake fails.
    or(Mono<Void> fallback)
    Specifies a fallback action to execute when the opening handshake fails.
  • Method Details

    • handler

      WebSocket<A,B> handler(WebSocketExchangeHandler<? super A,B> handler)

      Specifies the handler used to handle the WebSocket exchange.

      Parameters:
      handler - a WebSocket exchange handler
      Returns:
      this WebSocket
    • or

      default WebSocket<A,B> or(Runnable fallback)

      Specifies the fallback action to execute when the opening handshake fails.

      Unlike or(reactor.core.publisher.Mono), the specified fallback action is executed synchronously and might block the I/O thread.

      This is a convenience method which delegates to or(reactor.core.publisher.Mono) which should be prefered.

      Parameters:
      fallback - a fallback action
      Returns:
      this WebSocket
    • or

      WebSocket<A,B> or(Mono<Void> fallback)

      Specifies a fallback action to execute when the opening handshake fails.

      Unlike or(java.lang.Runnable), the specified fallback action is executed asynchronously and will not block the I/O thread.

      Parameters:
      fallback - a fallback action
      Returns:
      this WebSocket