Interface TransactionalPacketRegistry
-
- All Superinterfaces:
PacketRegistry
- All Known Subinterfaces:
BasicPacketChannel
,PacketChannel
public interface TransactionalPacketRegistry extends PacketRegistry
A registry for packets and their bindings. Also supports transactional packets.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <P extends RequestPacket<R>,R extends Packet>
TransactionalPacketBinding<P,R>registerTransactional(java.lang.Class<P> requestPacketType, int packetOpcode)
Register a request packet class pair to this channel.<P extends RequestPacket<R>,R extends Packet>
FixedTransactionalPacketBinding<P,R>registerTransactional(java.lang.Class<P> requestPacketType, java.lang.Class<R> responsePacketType, int packetOpcode)
Register a request/response packet class pair to this channel.<P extends RequestPacket<R>,R extends Packet>
java.util.Optional<TransactionalPacketBinding<P,R>>transactionalBinding(java.lang.Class<P> requestPacketType)
Gets theTransactionalPacketBinding
for the givenRequestPacket
class, if the type is registered to this channel as a transactional binding.-
Methods inherited from interface org.spongepowered.api.network.channel.packet.PacketRegistry
binding, binding, bindings, register
-
-
-
-
Method Detail
-
registerTransactional
<P extends RequestPacket<R>,R extends Packet> FixedTransactionalPacketBinding<P,R> registerTransactional(java.lang.Class<P> requestPacketType, java.lang.Class<R> responsePacketType, int packetOpcode)
Register a request/response packet class pair to this channel. A receiving handler isn't required when sending the request usingTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket)
.The response packet type may be reused by multiple request types.
- Type Parameters:
P
- The type of the request packetR
- The type of the response packet- Parameters:
packetOpcode
- A unique opcode for this request/response packet type pairrequestPacketType
- The type of the request packet being registeredresponsePacketType
- The type of the response packet being registered- Returns:
- The created transactional packet binding
-
registerTransactional
<P extends RequestPacket<R>,R extends Packet> TransactionalPacketBinding<P,R> registerTransactional(java.lang.Class<P> requestPacketType, int packetOpcode)
Register a request packet class pair to this channel. A receiving handler isn't required when sending the request usingTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket)
.Unlike packets registered using
registerTransactional(Class, Class, int)
, multiple response packet types are allowed for the request type. But they need to be registered usingPacketRegistry.register(Class, int)
.- Type Parameters:
P
- The type of the request packetR
- The type of the response packet- Parameters:
packetOpcode
- A unique opcode for this request packet typerequestPacketType
- The type of the request packet being registered- Returns:
- The created transactional packet binding
-
transactionalBinding
<P extends RequestPacket<R>,R extends Packet> java.util.Optional<TransactionalPacketBinding<P,R>> transactionalBinding(java.lang.Class<P> requestPacketType)
Gets theTransactionalPacketBinding
for the givenRequestPacket
class, if the type is registered to this channel as a transactional binding.- Type Parameters:
P
- The type of the request packetR
- The type of the response packet- Parameters:
requestPacketType
- The request packet type- Returns:
- The transactional packet binding, if found
-
-