Interface TransactionalPacketDispatcher

    • Method Detail

      • sendTo

        default <R extends PacketCompletableFuture<R> sendTo​(ServerPlayer player,
                                                               RequestPacket<R> packet)
        Sends the Packet to the player using this channel. This method returns a CompletableFuture that will be accepted once the response is received.

        The CompletableFuture may fail exceptionally by a NoResponseException if there wasn't a valid response received for the given request.

        A exception will be thrown if the specified packet type isn't registered in this PacketChannel.

        Type Parameters:
        R - The type of the response packet
        Parameters:
        player - The player to send the packet to
        packet - The request packet to send
        Returns:
        The completable future to handle the response packet and exceptions
        Throws:
        IllegalArgumentException - If the given packet type isn't registered in this channel binding
      • sendTo

        <R extends PacketCompletableFuture<R> sendTo​(EngineConnection connection,
                                                       RequestPacket<R> packet)
        Sends the Packet to the client using this channel. This method returns a CompletableFuture that will be accepted once the response is received.

        The CompletableFuture may fail exceptionally by a NoResponseException if there wasn't a valid response received for the given request.

        A exception will be thrown if the specified packet type isn't registered in this PacketChannel.

        Type Parameters:
        R - The type of the response packet
        Parameters:
        connection - The player connection to send the packet to
        packet - The request packet to send
        Returns:
        The completable future to handle the response packet and exceptions
        Throws:
        IllegalArgumentException - If the given packet type isn't registered in this channel binding
      • sendToServer

        default <R extends PacketCompletableFuture<R> sendToServer​(RequestPacket<R> packet)
        Sends the Packet to the server using this channel. This method returns a CompletableFuture that will be accepted once the response is received.

        The CompletableFuture may fail exceptionally by a NoResponseException if there wasn't a valid response received for the given request.

        A exception will be thrown if the specified packet type isn't registered in this PacketChannel.

        Type Parameters:
        R - The type of the response packet
        Parameters:
        packet - The packet to send to the server
        Returns:
        The completable future to handle the response packet and exceptions