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<S extends EngineConnectionState>
TransactionalPacketBinding<P, R> addResponseHandler
(Class<S> connectionState, PacketHandler<? super R, ? super S> responseHandler) Adds aPacketHandler
to handle a responsePacket
on for a specific connection type.<S extends EngineConnectionState>
TransactionalPacketBinding<P, R> addResponseHandler
(Class<S> connectionState, ResponsePacketHandler<? super P, ? super R, ? super S> handler) Adds aResponsePacketHandler
to handle a responsePacket
for a specific connection type.addResponseHandler
(PacketHandler<? super R, EngineConnectionState> handler) Adds aPacketHandler
to handle a responsePacket
on both platform sides.addResponseHandler
(ResponsePacketHandler<? super P, ? super R, EngineConnectionState> handler) Adds aResponsePacketHandler
to handle a responsePacket
on both platform sides.int
opcode()
Gets the opcode of theTransactionalPacketBinding
.Gets the type of theRequestPacket
.<S extends EngineConnectionState>
TransactionalPacketBinding<P, R> setRequestHandler
(Class<S> connectionState, RequestPacketHandler<? super P, ? extends R, ? super S> handler) Sets theRequestPacketHandler
to handle aRequestPacket
for a specific connection type.setRequestHandler
(RequestPacketHandler<? super P, ? extends R, EngineConnectionState> handler) Sets theRequestPacketHandler
to handle aRequestPacket
on both connection sides.
-
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
<S extends EngineConnectionState> TransactionalPacketBinding<P,R> setRequestHandler(Class<S> connectionState, RequestPacketHandler<? super P, ? extends R, ? super S> 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:
S
- The connection state- Parameters:
connectionState
- The connection state 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, EngineConnectionState> 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
<S extends EngineConnectionState> TransactionalPacketBinding<P,R> addResponseHandler(Class<S> connectionState, PacketHandler<? super R, ? super S> 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:
S
- The connection state- Parameters:
connectionState
- The connection state the response packet should be handled byresponseHandler
- The handler of the response packet- Returns:
- This packet binding, for chaining
-
addResponseHandler
<S extends EngineConnectionState> TransactionalPacketBinding<P,R> addResponseHandler(Class<S> connectionState, ResponsePacketHandler<? super P, ? super R, ? super S> 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:
S
- The connection state- Parameters:
connectionState
- The connection state 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, EngineConnectionState> 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, EngineConnectionState> 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
-