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 thePacketto the player using this channel.<R extends Packet>
CompletableFuture<R> sendTo(EngineConnection connection, RequestPacket<R> packet) Sends thePacketto the client using this channel.default <R extends Packet>
CompletableFuture<R> sendToServer(RequestPacket<R> packet) Sends thePacketto 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 thePacketto the player using this channel. This method returns aCompletableFuturethat will be accepted once the response is received.The
CompletableFuturemay fail exceptionally by aNoResponseExceptionif 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 thePacketto the client using this channel. This method returns aCompletableFuturethat will be accepted once the response is received.The
CompletableFuturemay fail exceptionally by aNoResponseExceptionif 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 thePacketto the server using this channel. This method returns aCompletableFuturethat will be accepted once the response is received.The
CompletableFuturemay fail exceptionally by aNoResponseExceptionif 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
-