Interface WebSocketSubprotocolHandler

  • All Known Implementing Classes:
    GraphQLTransportWSSubprotocolHandler, GraphQLWSSubprotocolHandler

    public interface WebSocketSubprotocolHandler
    An implementation of this interface is responsible for handling a particular subscription websocket protocol. It is responsible for registering a handler to listen for messages on the websocket, and then use the provided `MultiEmitter` and `UniEmitter` objects to emit individual responses (or failures).
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void cancelMulti​(String operationId)
      Cancels an active subscription with the given ID.
      void cancelUni​(String operationId)
      Cancels an active single-result operation with the given ID.
      void close()
      Called when the websocket should be closed (for example, when the GraphQL client is being closed).
      io.smallrye.mutiny.Uni<Void> ensureInitialized()
      This is called to initialize the websocket connection and prepare it for executing operations.
      String executeMulti​(javax.json.JsonObject request, io.smallrye.mutiny.subscription.MultiEmitter<? super String> emitter)
      Requests an execution of a subscription operation over the websocket.
      String executeUni​(javax.json.JsonObject request, io.smallrye.mutiny.subscription.UniEmitter<? super String> emitter)
      Requests an execution of a single-result operation over the websocket.
    • Method Detail

      • ensureInitialized

        io.smallrye.mutiny.Uni<Void> ensureInitialized()
        This is called to initialize the websocket connection and prepare it for executing operations. The returned Uni is completed when the websocket is fully initialized (including necessary server ACKs specific to the protocol). If the handler is already fully initialized, this returns a completed Uni.
      • executeUni

        String executeUni​(javax.json.JsonObject request,
                          io.smallrye.mutiny.subscription.UniEmitter<? super String> emitter)
        Requests an execution of a single-result operation over the websocket.
        Parameters:
        request - Request in full JSON format describing the operation to be executed.
        emitter - Emitter that should receive the completion event (or an error) when the operation finishes.
        Returns:
        The generated internal ID of this operation.
      • executeMulti

        String executeMulti​(javax.json.JsonObject request,
                            io.smallrye.mutiny.subscription.MultiEmitter<? super String> emitter)
        Requests an execution of a subscription operation over the websocket.
        Parameters:
        request - Request in full JSON format describing the operation to be executed.
        emitter - Emitter that should receive the completion events (or an error) from the subscription.
        Returns:
        The generated internal ID of this operation.
      • cancelUni

        void cancelUni​(String operationId)
        Cancels an active single-result operation with the given ID. This does not do anything with the Emitter for this operation, it only sends a cancellation message to the server (if applicable depending on the protocol), and marks this operation as finished.
        Parameters:
        operationId - ID of the operation (returned from calling `executeUni`)
      • cancelMulti

        void cancelMulti​(String operationId)
        Cancels an active subscription with the given ID. This does not do anything with the Emitter for this operation, it only sends a cancellation message to the server (if applicable depending on the protocol), and marks this operation as finished.
        Parameters:
        operationId - ID of the operation (returned from calling `executeMulti`)
      • close

        void close()
        Called when the websocket should be closed (for example, when the GraphQL client is being closed).