Interface TransactionalPacketBinding<P extends RequestPacket<R>,R extends Packet>
-
- Type Parameters:
P- The type of the request packetR- The type of the response packet
- All Superinterfaces:
PacketBinding<P>
- All Known Subinterfaces:
FixedTransactionalPacketBinding<P,R>
public interface TransactionalPacketBinding<P extends RequestPacket<R>,R extends Packet> extends PacketBinding<P>
A packet binding that represents a request/response pair. One side of a connection can send aRequestPacketand the other side will normally respond with a responsePacket.Request/response pairs share an opcode, a additional byte will specify whether it's a request, response or a no-response.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <C extends EngineConnection>
TransactionalPacketBinding<P,R>addResponseHandler(java.lang.Class<C> connectionType, PacketHandler<? super R,? super C> responseHandler)Adds aPacketHandlerto handle a responsePacketon for a specific connection type.<C extends EngineConnection>
TransactionalPacketBinding<P,R>addResponseHandler(java.lang.Class<C> connectionType, ResponsePacketHandler<? super P,? super R,? super C> handler)Adds aResponsePacketHandlerto handle a responsePacketfor a specific connection type.TransactionalPacketBinding<P,R>addResponseHandler(PacketHandler<? super R,EngineConnection> handler)Adds aPacketHandlerto handle a responsePacketon both platform sides.TransactionalPacketBinding<P,R>addResponseHandler(ResponsePacketHandler<? super P,? super R,EngineConnection> handler)Adds aResponsePacketHandlerto handle a responsePacketon both platform sides.<C extends EngineConnection>
TransactionalPacketBinding<P,R>addResponseHandler(EngineConnectionSide<C> side, PacketHandler<? super R,? super C> handler)Adds aPacketHandlerto handle a responsePacketon a specific connection side.<C extends EngineConnection>
TransactionalPacketBinding<P,R>addResponseHandler(EngineConnectionSide<C> side, ResponsePacketHandler<? super P,? super R,? super C> handler)Adds aResponsePacketHandlerto handle a responsePacketon a specific connection side.intopcode()Gets the opcode of theTransactionalPacketBinding.java.lang.Class<P>packetType()Gets the type of theRequestPacket.<C extends EngineConnection>
TransactionalPacketBinding<P,R>setRequestHandler(java.lang.Class<C> connectionType, RequestPacketHandler<? super P,? extends R,? super C> handler)Sets theRequestPacketHandlerto handle aRequestPacketfor a specific connection type.TransactionalPacketBinding<P,R>setRequestHandler(RequestPacketHandler<? super P,? extends R,EngineConnection> handler)Sets theRequestPacketHandlerto handle aRequestPacketon both connection sides.<C extends EngineConnection>
TransactionalPacketBinding<P,R>setRequestHandler(EngineConnectionSide<C> side, RequestPacketHandler<? super P,? extends R,? super C> handler)Sets theRequestPacketHandlerto handle aRequestPacketon a specific connection side.
-
-
-
Method Detail
-
opcode
int opcode()
Gets the opcode of theTransactionalPacketBinding. This opcode will be shared by the request and responsePackets.- Specified by:
opcodein interfacePacketBinding<P extends RequestPacket<R>>- Returns:
- The opcode
-
packetType
java.lang.Class<P> packetType()
Gets the type of theRequestPacket.- Specified by:
packetTypein interfacePacketBinding<P extends RequestPacket<R>>- Returns:
- The request packet type
-
setRequestHandler
<C extends EngineConnection> TransactionalPacketBinding<P,R> setRequestHandler(EngineConnectionSide<C> side, RequestPacketHandler<? super P,? extends R,? super C> handler)
Sets theRequestPacketHandlerto handle aRequestPacketon a specific connection side. The difference with a normalPacketHandleris that it requires a responsePacketas return value.- Type Parameters:
C- The connection type- Parameters:
side- The side the request packet should be handled onhandler- The handler of the request packet- Returns:
- This packet binding, for chaining
-
setRequestHandler
<C extends EngineConnection> TransactionalPacketBinding<P,R> setRequestHandler(java.lang.Class<C> connectionType, RequestPacketHandler<? super P,? extends R,? super C> handler)
Sets theRequestPacketHandlerto handle aRequestPacketfor a specific connection type. The difference with a normalPacketHandleris that it requires a responsePacketas return value.- Type Parameters:
C- The connection type- Parameters:
connectionType- The connection type the request packet should be handled byhandler- The handler of the request packet- Returns:
- This packet binding, for chaining
-
setRequestHandler
TransactionalPacketBinding<P,R> setRequestHandler(RequestPacketHandler<? super P,? extends R,EngineConnection> handler)
Sets theRequestPacketHandlerto handle aRequestPacketon both connection sides. The difference with a normalPacketHandleris that it requires a responsePacketas return value.- Parameters:
handler- The handler of the request packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
<C extends EngineConnection> TransactionalPacketBinding<P,R> addResponseHandler(EngineConnectionSide<C> side, PacketHandler<? super R,? super C> handler)
Adds aPacketHandlerto handle a responsePacketon a specific connection side.Binding a response
PacketHandleris completely optional. It is also possible to append a handler to theCompletableFuturereturned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket).- Type Parameters:
C- The connection type- Parameters:
side- The side the response packet should be handled onhandler- The handler of the response packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
<C extends EngineConnection> TransactionalPacketBinding<P,R> addResponseHandler(java.lang.Class<C> connectionType, PacketHandler<? super R,? super C> responseHandler)
Adds aPacketHandlerto handle a responsePacketon for a specific connection type.Binding a response
PacketHandleris completely optional. It is also possible to append a handler to theCompletableFuturereturned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket).- Type Parameters:
C- The connection type- Parameters:
connectionType- The connection type the response packet should be handled byresponseHandler- The handler of the response packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
<C extends EngineConnection> TransactionalPacketBinding<P,R> addResponseHandler(EngineConnectionSide<C> side, ResponsePacketHandler<? super P,? super R,? super C> handler)
Adds aResponsePacketHandlerto handle a responsePacketon a specific connection side.Binding a response
PacketHandleris completely optional. It is also possible to append a handler to theCompletableFuturereturned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket).- Type Parameters:
C- The connection type- Parameters:
side- The side the response packet should be handled onhandler- The handler of the response packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
<C extends EngineConnection> TransactionalPacketBinding<P,R> addResponseHandler(java.lang.Class<C> connectionType, ResponsePacketHandler<? super P,? super R,? super C> handler)
Adds aResponsePacketHandlerto handle a responsePacketfor a specific connection type.Binding a response
PacketHandleris completely optional. It is also possible to append a handler to theCompletableFuturereturned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket).- Type Parameters:
C- The connection type- Parameters:
connectionType- The connection type the response packet should be handled byhandler- The handler of the response packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
TransactionalPacketBinding<P,R> addResponseHandler(PacketHandler<? super R,EngineConnection> handler)
Adds aPacketHandlerto handle a responsePacketon both platform sides.Binding a response
PacketHandleris completely optional. It is also possible to append a handler to theCompletableFuturereturned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket).- Parameters:
handler- The handler of the response packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
TransactionalPacketBinding<P,R> addResponseHandler(ResponsePacketHandler<? super P,? super R,EngineConnection> handler)
Adds aResponsePacketHandlerto handle a responsePacketon both platform sides.Binding a response
PacketHandleris completely optional. It is also possible to append a handler to theCompletableFuturereturned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket).- Parameters:
handler- The handler of the response packet- Returns:
- This packet binding, for chaining
-
-