#include <icy/net/transaction.h>Inherits:
PacketTransaction< PacketT >,PacketSocketEmitter
Request/response helper for packet types emitted from a socket.
| Return | Name | Description |
|---|---|---|
Transaction inline | Constructs a Transaction on the given socket targeting peerAddress. | |
bool | send virtual inline | Sends the request packet to the peer address and starts the timeout timer. Sets state to Failed and returns false if the packet could not be sent. |
void | cancel virtual inline | Cancels the transaction and stops the timeout timer. |
void | dispose virtual inline | Stops the timer and unregisters callbacks. |
Address | peerAddress const inline | Returns the remote peer address used for this transaction. |
inline
inline Transaction(const net::Socket::Ptr & socket, const Address & peerAddress, int timeout, int retries)Constructs a Transaction on the given socket targeting peerAddress.
socket The socket to send/receive packets on.
peerAddress The remote address for the request and response matching.
timeout Milliseconds to wait for a response before failing.
retries Number of additional send attempts on timeout.
virtual inline
virtual inline bool send()Sends the request packet to the peer address and starts the timeout timer. Sets state to Failed and returns false if the packet could not be sent.
true if the packet was sent and the timer started successfully.
virtual inline
virtual inline void cancel()Cancels the transaction and stops the timeout timer.
virtual inline
virtual inline void dispose()Stops the timer and unregisters callbacks.
const inline
inline Address peerAddress() constReturns the remote peer address used for this transaction.
| Return | Name | Description |
|---|---|---|
Address | _peerAddress |
Address _peerAddress| Return | Name | Description |
|---|---|---|
bool | onPacket virtual inline | Checks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops. |
void | onResponse virtual inline | Called when a confirmed response is received; emits the response via PacketSignal. |
bool | checkResponse virtual inline | Returns true if packet is a valid response for this transaction. |
virtual inline
virtual inline bool onPacket(IPacket & packet)Checks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops.
packet The received packet to test.true to stop further propagation of the socket data event.
virtual inline
virtual inline void onResponse()Called when a confirmed response is received; emits the response via PacketSignal.
virtual inline
virtual inline bool checkResponse(const PacketT & packet)Returns true if packet is a valid response for this transaction.
The base implementation matches the local socket address against the PacketInfo socket address and the stored peer address against the PacketInfo peer address. Subclasses may override for stricter matching.
packet The candidate response packet.true if the packet satisfies the response criteria.
| Name | Description |
|---|---|
BaseT |
PacketTransaction< PacketT > BaseT()