Interface TransactionalPacketDispatcher

All Superinterfaces:
PacketDispatcher
All Known Subinterfaces:
BasicHandshakePacketDispatcher, PacketChannel

public interface TransactionalPacketDispatcher extends PacketDispatcher
A packet dispatcher which supports transactional packets.
  • Method Details

    • sendTo

      default <R extends Packet> CompletableFuture<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 Packet> CompletableFuture<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 Packet> CompletableFuture<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