Interface WebSocketAdapter

  • All Superinterfaces:
    AutoCloseable, Closeable

    public interface WebSocketAdapter
    extends Closeable
    Basic websocket application interface facilitating different provider implementations. See implementation documentation to understand specific configuration options.
    • Method Detail

      • start

        WebSocketAdapter start()
        Start the websocket client and connect to the remote endpoint.
        Returns:
        this instance supporting a fluent API
      • sendObject

        Promise<Void,​IOException> sendObject​(Object request)
        Send the supplied request over the websocket to the remote party.
        Parameters:
        request - The request to transmit
        Returns:
        Promise of any IOException that occurred in the event of a send failure
      • openHandler

        WebSocketAdapter openHandler​(Consumer<WebSocketAdapter> openHandler)
        Supply an open handler executed once the websocket connection is established and completed. The handler is called once on the connection being successfully established and on any successful reconnections.
        Parameters:
        openHandler - the open handler (not null)
        Returns:
        this instance supporting a fluent API
      • closeHandler

        WebSocketAdapter closeHandler​(Consumer<Void> closeHandler)
        Supply a close handler executed once the client websocket connection being closed. That is, if the websocket is closed using its close() method then this handler will be executed on completion. It is not called on remote websocket disconnections or exceptions.
        Parameters:
        closeHandler - the close handler (not null)
        Returns:
        this instance supporting a fluent API
      • messageHandler

        WebSocketAdapter messageHandler​(Consumer<JsonValue> messageHandler)
        Supply a message handler capable of consuming server requests. The handler is called on receipt of a message on the websocket.
        Parameters:
        messageHandler - the message handler (not null)
        Returns:
        this instance supporting a fluent API
      • exceptionHandler

        WebSocketAdapter exceptionHandler​(Consumer<Throwable> exceptionHandler)
        Supply an exception handler capable of consuming websocket exceptions. The exception handler is called in the event of exceptions on the websocket and after reconnection attempts have failed.
        Parameters:
        exceptionHandler - the exception handler (not null)
        Returns:
        this instance supporting a fluent API
      • subprotocols

        WebSocketAdapter subprotocols​(List<String> subprotocols)
        Supply a list of protocols supported by this websocket client.
        Parameters:
        subprotocols - the supported subprotocols (not null)
        Returns:
        this instance supporting a fluent API
      • ssoHeader

        WebSocketAdapter ssoHeader​(String headerName,
                                   String token)
        Provide values for a SSO token header.
        Parameters:
        headerName - The SSO header name (not null)
        token - The SSO token value (not null)
        Returns:
        this instance supporting a fluent API
      • reconnect

        WebSocketAdapter reconnect​(Duration reconnectDelay)
        Supply reconnect configuration to support reconnection attempts should the websocket be terminated remotely. This includes constraining the reconnection attempts to execute with a delay of reconnectDelay seconds.
        Parameters:
        reconnectDelay - the relay after which a reconnect will be attempted, in seconds (not null)
        Returns:
        this instance supporting a fluent API