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>
RequestPacket
and the other side will normally respond with a
response Packet
.
Request/response pairs share an opcode, a additional byte will specify whether it's a request, response or a no-response.
-
Method Summary
Modifier and TypeMethodDescription<C extends EngineConnection>
TransactionalPacketBinding<P,R> addResponseHandler
(Class<C> connectionType, PacketHandler<? super R, ? super C> responseHandler) Adds aPacketHandler
to handle a responsePacket
on for a specific connection type.<C extends EngineConnection>
TransactionalPacketBinding<P,R> addResponseHandler
(Class<C> connectionType, ResponsePacketHandler<? super P, ? super R, ? super C> handler) Adds aResponsePacketHandler
to handle a responsePacket
for a specific connection type.addResponseHandler
(PacketHandler<? super R, EngineConnection> handler) Adds aPacketHandler
to handle a responsePacket
on both platform sides.addResponseHandler
(ResponsePacketHandler<? super P, ? super R, EngineConnection> handler) Adds aResponsePacketHandler
to handle a responsePacket
on both platform sides.<C extends EngineConnection>
TransactionalPacketBinding<P,R> addResponseHandler
(EngineConnectionSide<C> side, PacketHandler<? super R, ? super C> handler) Adds aPacketHandler
to handle a responsePacket
on a specific connection side.<C extends EngineConnection>
TransactionalPacketBinding<P,R> addResponseHandler
(EngineConnectionSide<C> side, ResponsePacketHandler<? super P, ? super R, ? super C> handler) Adds aResponsePacketHandler
to handle a responsePacket
on a specific connection side.int
opcode()
Gets the opcode of theTransactionalPacketBinding
.Gets the type of theRequestPacket
.<C extends EngineConnection>
TransactionalPacketBinding<P,R> setRequestHandler
(Class<C> connectionType, RequestPacketHandler<? super P, ? extends R, ? super C> handler) Sets theRequestPacketHandler
to handle aRequestPacket
for a specific connection type.setRequestHandler
(RequestPacketHandler<? super P, ? extends R, EngineConnection> handler) Sets theRequestPacketHandler
to handle aRequestPacket
on both connection sides.<C extends EngineConnection>
TransactionalPacketBinding<P,R> setRequestHandler
(EngineConnectionSide<C> side, RequestPacketHandler<? super P, ? extends R, ? super C> handler) Sets theRequestPacketHandler
to handle aRequestPacket
on a specific connection side.
-
Method Details
-
opcode
int opcode()Gets the opcode of theTransactionalPacketBinding
. This opcode will be shared by the request and responsePacket
s.- Specified by:
opcode
in interfacePacketBinding<P extends RequestPacket<R>>
- Returns:
- The opcode
-
packetType
Gets the type of theRequestPacket
.- Specified by:
packetType
in 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 theRequestPacketHandler
to handle aRequestPacket
on a specific connection side. The difference with a normalPacketHandler
is that it requires a responsePacket
as 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(Class<C> connectionType, RequestPacketHandler<? super P, ? extends R, ? super C> handler) Sets theRequestPacketHandler
to handle aRequestPacket
for a specific connection type. The difference with a normalPacketHandler
is that it requires a responsePacket
as 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 theRequestPacketHandler
to handle aRequestPacket
on both connection sides. The difference with a normalPacketHandler
is that it requires a responsePacket
as 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 aPacketHandler
to handle a responsePacket
on a specific connection side.Binding a response
PacketHandler
is completely optional. It is also possible to append a handler to theCompletableFuture
returned 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(Class<C> connectionType, PacketHandler<? super R, ? super C> responseHandler) Adds aPacketHandler
to handle a responsePacket
on for a specific connection type.Binding a response
PacketHandler
is completely optional. It is also possible to append a handler to theCompletableFuture
returned 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 aResponsePacketHandler
to handle a responsePacket
on a specific connection side.Binding a response
PacketHandler
is completely optional. It is also possible to append a handler to theCompletableFuture
returned 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(Class<C> connectionType, ResponsePacketHandler<? super P, ? super R, ? super C> handler) Adds aResponsePacketHandler
to handle a responsePacket
for a specific connection type.Binding a response
PacketHandler
is completely optional. It is also possible to append a handler to theCompletableFuture
returned 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 aPacketHandler
to handle a responsePacket
on both platform sides.Binding a response
PacketHandler
is completely optional. It is also possible to append a handler to theCompletableFuture
returned 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 aResponsePacketHandler
to handle a responsePacket
on both platform sides.Binding a response
PacketHandler
is completely optional. It is also possible to append a handler to theCompletableFuture
returned byTransactionalPacketDispatcher.sendTo(EngineConnection, RequestPacket)
.- Parameters:
handler
- The handler of the response packet- Returns:
- This packet binding, for chaining
-