Interface TransactionalPacketDispatcher
- All Superinterfaces:
PacketDispatcher
- All Known Subinterfaces:
BasicHandshakePacketDispatcher
,PacketChannel
A packet dispatcher which supports transactional packets.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R extends Packet>
CompletableFuture<R>sendTo
(ServerPlayer player, RequestPacket<R> packet) Sends thePacket
to the player using this channel.<R extends Packet>
CompletableFuture<R>sendTo
(EngineConnection connection, RequestPacket<R> packet) Sends thePacket
to the client using this channel.default <R extends Packet>
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 Details
-
sendTo
default <R extends Packet> 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:
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 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:
IllegalArgumentException
- If the given packet type isn't registered in this channel binding
-
sendToServer
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
-