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 aRequestPacket
and 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(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.TransactionalPacketBinding<P,R>
addResponseHandler(PacketHandler<? super R,EngineConnection> handler)
Adds aPacketHandler
to handle a responsePacket
on both platform sides.TransactionalPacketBinding<P,R>
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
.Class<P>
packetType()
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.TransactionalPacketBinding<P,R>
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 Detail
-
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
Class<P> 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
-
-