Interface TransactionalPacketDispatcher
-
- All Superinterfaces:
PacketDispatcher
- All Known Subinterfaces:
BasicHandshakePacketDispatcher
,PacketChannel
public interface TransactionalPacketDispatcher extends PacketDispatcher
A packet dispatcher which supports transactional packets.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <R extends Packet>
java.util.concurrent.CompletableFuture<R>sendTo(ServerPlayer player, RequestPacket<R> packet)
Sends thePacket
to the player using this channel.<R extends Packet>
java.util.concurrent.CompletableFuture<R>sendTo(EngineConnection connection, RequestPacket<R> packet)
Sends thePacket
to the client using this channel.default <R extends Packet>
java.util.concurrent.CompletableFuture<R>sendToServer(RequestPacket<R> packet)
Sends thePacket
to the server using this channel.-
Methods inherited from interface org.spongepowered.api.network.channel.packet.PacketDispatcher
isSupportedBy, sendTo, sendTo, sendToAllPlayers, sendToAllPlayersIn, sendToServer
-
-
-
-
Method Detail
-
sendTo
default <R extends Packet> java.util.concurrent.CompletableFuture<R> sendTo(ServerPlayer player, RequestPacket<R> packet)
Sends thePacket
to the player using this channel. This method returns aCompletableFuture
that will be accepted once the response is received.The
CompletableFuture
may fail exceptionally by aNoResponseException
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 topacket
- The request packet to send- Returns:
- The completable future to handle the response packet and exceptions
- Throws:
java.lang.IllegalArgumentException
- If the given packet type isn't registered in this channel binding
-
sendTo
<R extends Packet> java.util.concurrent.CompletableFuture<R> sendTo(EngineConnection connection, RequestPacket<R> packet)
Sends thePacket
to the client using this channel. This method returns aCompletableFuture
that will be accepted once the response is received.The
CompletableFuture
may fail exceptionally by aNoResponseException
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 topacket
- The request packet to send- Returns:
- The completable future to handle the response packet and exceptions
- Throws:
java.lang.IllegalArgumentException
- If the given packet type isn't registered in this channel binding
-
sendToServer
default <R extends Packet> java.util.concurrent.CompletableFuture<R> sendToServer(RequestPacket<R> packet)
Sends thePacket
to the server using this channel. This method returns aCompletableFuture
that will be accepted once the response is received.The
CompletableFuture
may fail exceptionally by aNoResponseException
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
-
-