# PacketTransaction

<a id="packettransaction"></a>

# PacketTransaction

```cpp
#include <icy/packettransaction.h>

template<class PacketT>
class PacketTransaction
```

[Defined in src/base/include/icy/packettransaction.h:70](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L70)

> **Inherits:** [`Sendable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#sendable), [`Stateful< TransactionState >`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful), [`RefCounted< PacketTransaction< PacketT > >`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted)
> **Subclassed by:** [`Transaction< Message >`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#transaction), [`Transaction< PacketT >`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#transaction)

Request/response transaction with timeout and retry logic.

Lifetime is managed by [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) via the [RefCounted](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) base class. The transaction is kept alive as long as at least one [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) references it. The owning client holds a Ptr in its transaction list; callbacks should capture a Ptr copy to prevent premature deletion.

When a terminal state (Success or Failed) is reached, the transaction cleans up its timer but does NOT delete itself. The [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) destructor handles deletion when the last reference is released.

## List of all members

| Name | Kind | Owner |
|------|------|-------|
| [`IntrusivePtr`](#intrusiveptr-9) | `friend` | Declared here |
| [`PacketTransaction`](#packettransaction-1) | `function` | Declared here |
| [`PacketTransaction`](#packettransaction-2) | `function` | Declared here |
| [`send`](#send) | `function` | Declared here |
| [`cancel`](#cancel-1) | `function` | Declared here |
| [`cancelled`](#cancelled) | `function` | Declared here |
| [`dispose`](#dispose) | `function` | Declared here |
| [`disposed`](#disposed) | `function` | Declared here |
| [`canResend`](#canresend) | `function` | Declared here |
| [`attempts`](#attempts) | `function` | Declared here |
| [`retries`](#retries) | `function` | Declared here |
| [`request`](#request) | `function` | Declared here |
| [`request`](#request-1) | `function` | Declared here |
| [`response`](#response) | `function` | Declared here |
| [`response`](#response-1) | `function` | Declared here |
| [`_request`](#_request) | `variable` | Declared here |
| [`_response`](#_response) | `variable` | Declared here |
| [`_timer`](#_timer) | `variable` | Declared here |
| [`_retries`](#_retries) | `variable` | Declared here |
| [`_attempts`](#_attempts) | `variable` | Declared here |
| [`_disposed`](#_disposed) | `variable` | Declared here |
| [`~PacketTransaction`](#packettransaction-3) | `function` | Declared here |
| [`onStateChange`](#onstatechange-1) | `function` | Declared here |
| [`handlePotentialResponse`](#handlepotentialresponse) | `function` | Declared here |
| [`checkResponse`](#checkresponse) | `function` | Declared here |
| [`onResponse`](#onresponse) | `function` | Declared here |
| [`onTimeout`](#ontimeout) | `function` | Declared here |
| [`Ptr`](#ptr-3) | `typedef` | Declared here |
| [`send`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#send-10) | `function` | Inherited from [`Sendable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#sendable) |
| [`cancel`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#cancel-8) | `function` | Inherited from [`Sendable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#sendable) |
| [`StateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#statechange) | `variable` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful-1) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`~Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful-2) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`stateEquals`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateequals) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`stateBetween`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#statebetween) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`state`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#state-4) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`state`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#state-5) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`_state`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#_state) | `variable` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`beforeStateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#beforestatechange) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`onStateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#onstatechange-2) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`setState`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#setstate) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`setState`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#setstate-1) | `function` | Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful) |
| [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted-1) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted-2) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#operator-78) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`addRef`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#addref) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`releaseRef`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#releaseref) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`refCount`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcount) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`~RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted-3) | `function` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |
| [`_refCount`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#_refcount) | `variable` | Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted) |

## Inherited from [`Sendable`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#sendable)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`send`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#send-10) `virtual` | Initiates the send operation. |
| `function` | [`cancel`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#cancel-8) `virtual` | Cancels a pending send operation. |

## Inherited from [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful)

| Kind | Name | Description |
|------|------|-------------|
| `variable` | [`StateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#statechange)  | Signals when the state changes. |
| `function` | [`Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful-1) `inline` |  |
| `function` | [`~Stateful`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateful-2) `virtual` `inline` |  |
| `function` | [`stateEquals`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#stateequals) `virtual` `const` `inline` | Returns true if the current state ID equals the given ID. |
| `function` | [`stateBetween`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#statebetween) `virtual` `const` `inline` | Returns true if the current state ID is in the inclusive range [lid, rid]. |
| `function` | [`state`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#state-4) `virtual` `inline` | Returns a mutable reference to the current state. |
| `function` | [`state`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#state-5) `virtual` `const` `inline` | Returns a copy of the current state. |
| `variable` | [`_state`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#_state)  |  |
| `function` | [`beforeStateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#beforestatechange) `virtual` `inline` | Override to handle pre state change logic. Return false to prevent state change. |
| `function` | [`onStateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#onstatechange-2) `virtual` `inline` | Override to handle post state change logic. |
| `function` | [`setState`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#setstate) `virtual` `inline` | Sets the state and sends the state signal if the state change was successful. |
| `function` | [`setState`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#setstate-1) `virtual` `inline` | Sets the state and sends the state signal if the state change was successful. |

## Inherited from [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted)

| Kind | Name | Description |
|------|------|-------------|
| `function` | [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted-1)  | Defaulted constructor. |
| `function` | [`RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted-2) `inline` `noexcept` |  |
| `function` | [`operator=`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#operator-78) `inline` `noexcept` |  |
| `function` | [`addRef`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#addref) `const` `inline` `noexcept` | Increments the reference count. Called by [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) on acquisition. |
| `function` | [`releaseRef`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#releaseref) `const` `inline` `noexcept` | Decrements the reference count. |
| `function` | [`refCount`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcount) `const` `inline` `noexcept` | Returns the current reference count. |
| `function` | [`~RefCounted`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#refcounted-3)  | Defaulted destructor. |
| `variable` | [`_refCount`](https://auscaster.com/icey/docs/api-reference/icy-RefCounted.md#_refcount)  |  |

## Friends

| Name | Description |
|------|-------------|
| [`IntrusivePtr`](#intrusiveptr-9)  |  |

---

<a id="intrusiveptr-9"></a>

### IntrusivePtr

```cpp
template<typename U> friend class IntrusivePtr
```

[Defined in src/base/include/icy/packettransaction.h:165](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L165)

## Public Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`PacketTransaction`](#packettransaction-1) `inline` |  |
|  | [`PacketTransaction`](#packettransaction-2) `inline` |  |
| `bool` | [`send`](#send) `virtual` `inline` `override` | Starts the transaction timer and sends the request. Overriding classes should implement send logic here. |
| `void` | [`cancel`](#cancel-1) `virtual` `inline` `override` | Cancellation means that the agent will not retransmit the request, will not treat the lack of response to be a failure, but will wait the duration of the transaction timeout for a response. Transitions the transaction to the `Cancelled` state. |
| `bool` | [`cancelled`](#cancelled) `const` `inline` |  |
| `void` | [`dispose`](#dispose) `virtual` `inline` | Stops the timer and unregisters callbacks. Does NOT delete the object; the [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) destructor handles deletion when the last reference is released. Safe to call multiple times. |
| `bool` | [`disposed`](#disposed) `const` `inline` |  |
| `bool` | [`canResend`](#canresend) `virtual` `inline` |  |
| `int` | [`attempts`](#attempts) `const` `inline` |  |
| `int` | [`retries`](#retries) `const` `inline` |  |
| `PacketT &` | [`request`](#request) `inline` |  |
| `PacketT` | [`request`](#request-1) `const` `inline` |  |
| `PacketT &` | [`response`](#response) `inline` |  |
| `PacketT` | [`response`](#response-1) `const` `inline` |  |

---

<a id="packettransaction-1"></a>

### PacketTransaction

`inline`

```cpp
inline PacketTransaction(long timeout = 10000, int retries = 0, uv::Loop * loop = uv::defaultLoop())
```

[Defined in src/base/include/icy/packettransaction.h:80](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L80)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `timeout` | `long` | Transaction timeout in milliseconds before failure or retry. |
| `retries` | `int` | Maximum number of retransmissions (0 means one attempt only). |
| `loop` | [`uv::Loop`](https://auscaster.com/icey/docs/api-reference/uv.md#loop-1) * | Event loop for the timeout timer. |

---

<a id="packettransaction-2"></a>

### PacketTransaction

`inline`

```cpp
inline PacketTransaction(const PacketT & request, long timeout = 10000, int retries = 0, uv::Loop * loop = uv::defaultLoop())
```

[Defined in src/base/include/icy/packettransaction.h:92](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L92)

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `request` | `const PacketT &` | Initial request packet to store and send. |
| `timeout` | `long` | Transaction timeout in milliseconds before failure or retry. |
| `retries` | `int` | Maximum number of retransmissions (0 means one attempt only). |
| `loop` | [`uv::Loop`](https://auscaster.com/icey/docs/api-reference/uv.md#loop-1) * | Event loop for the timeout timer. |

---

<a id="send"></a>

### send

`virtual` `inline` `override`

```cpp
virtual inline bool send() override
```

[Defined in src/base/include/icy/packettransaction.h:103](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L103)

Starts the transaction timer and sends the request. Overriding classes should implement send logic here.

#### Reimplements

- [`Sendable::send`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#send-10)

#### Reimplemented by

- [`Transaction::send`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#send-7)
- [`Transaction::send`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#send-7)

---

<a id="cancel-1"></a>

### cancel

`virtual` `inline` `override`

```cpp
virtual inline void cancel() override
```

[Defined in src/base/include/icy/packettransaction.h:122](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L122)

Cancellation means that the agent will not retransmit the request, will not treat the lack of response to be a failure, but will wait the duration of the transaction timeout for a response. Transitions the transaction to the `Cancelled` state.

#### Reimplements

- [`Sendable::cancel`](https://auscaster.com/icey/docs/api-reference/icy-basic-Sendable.md#cancel-8)

#### Reimplemented by

- [`Transaction::cancel`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#cancel-6)
- [`Transaction::cancel`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#cancel-6)

---

<a id="cancelled"></a>

### cancelled

`const` `inline`

```cpp
inline bool cancelled() const
```

[Defined in src/base/include/icy/packettransaction.h:125](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L125)

#### Returns
True if the transaction is in the `Cancelled` state.

---

<a id="dispose"></a>

### dispose

`virtual` `inline`

```cpp
virtual inline void dispose()
```

[Defined in src/base/include/icy/packettransaction.h:130](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L130)

Stops the timer and unregisters callbacks. Does NOT delete the object; the [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) destructor handles deletion when the last reference is released. Safe to call multiple times.

#### Reimplemented by

- [`Transaction::dispose`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#dispose-1)
- [`Transaction::dispose`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#dispose-1)

---

<a id="disposed"></a>

### disposed

`const` `inline`

```cpp
inline bool disposed() const
```

[Defined in src/base/include/icy/packettransaction.h:141](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L141)

#### Returns
True if [dispose()](#dispose) has been called.

---

<a id="canresend"></a>

### canResend

`virtual` `inline`

```cpp
virtual inline bool canResend()
```

[Defined in src/base/include/icy/packettransaction.h:144](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L144)

#### Returns
True if the transaction is not cancelled and has attempts remaining.

---

<a id="attempts"></a>

### attempts

`const` `inline`

```cpp
inline int attempts() const
```

[Defined in src/base/include/icy/packettransaction.h:147](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L147)

#### Returns
The number of times [`send()`](#send) has been called for this transaction.

---

<a id="retries"></a>

### retries

`const` `inline`

```cpp
inline int retries() const
```

[Defined in src/base/include/icy/packettransaction.h:150](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L150)

#### Returns
The configured maximum number of retransmissions.

---

<a id="request"></a>

### request

`inline`

```cpp
inline PacketT & request()
```

[Defined in src/base/include/icy/packettransaction.h:153](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L153)

#### Returns
Mutable reference to the outgoing request packet.

---

<a id="request-1"></a>

### request

`const` `inline`

```cpp
inline PacketT request() const
```

[Defined in src/base/include/icy/packettransaction.h:156](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L156)

#### Returns
Copy of the outgoing request packet.

---

<a id="response"></a>

### response

`inline`

```cpp
inline PacketT & response()
```

[Defined in src/base/include/icy/packettransaction.h:159](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L159)

#### Returns
Mutable reference to the received response packet.

---

<a id="response-1"></a>

### response

`const` `inline`

```cpp
inline PacketT response() const
```

[Defined in src/base/include/icy/packettransaction.h:162](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L162)

#### Returns
Copy of the received response packet.

## Protected Attributes

| Return | Name | Description |
|--------|------|-------------|
| `PacketT` | [`_request`](#_request)  |  |
| `PacketT` | [`_response`](#_response)  |  |
| [`Timer`](https://auscaster.com/icey/docs/api-reference/icy-Timer.md#timer) | [`_timer`](#_timer)  | The request timeout callback. |
| `int` | [`_retries`](#_retries)  | The maximum number of attempts before the transaction is considered failed. |
| `int` | [`_attempts`](#_attempts)  | The number of times the transaction has been sent. |
| `bool` | [`_disposed`](#_disposed)  |  |

---

<a id="_request"></a>

### _request

```cpp
PacketT _request
```

[Defined in src/base/include/icy/packettransaction.h:219](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L219)

---

<a id="_response"></a>

### _response

```cpp
PacketT _response
```

[Defined in src/base/include/icy/packettransaction.h:220](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L220)

---

<a id="_timer"></a>

### _timer

```cpp
Timer _timer
```

Type: [`Timer`](https://auscaster.com/icey/docs/api-reference/icy-Timer.md#timer)

[Defined in src/base/include/icy/packettransaction.h:221](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L221)

The request timeout callback.

---

<a id="_retries"></a>

### _retries

```cpp
int _retries
```

[Defined in src/base/include/icy/packettransaction.h:222](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L222)

The maximum number of attempts before the transaction is considered failed.

---

<a id="_attempts"></a>

### _attempts

```cpp
int _attempts
```

[Defined in src/base/include/icy/packettransaction.h:223](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L223)

The number of times the transaction has been sent.

---

<a id="_disposed"></a>

### _disposed

```cpp
bool _disposed = false
```

[Defined in src/base/include/icy/packettransaction.h:224](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L224)

## Protected Methods

| Return | Name | Description |
|--------|------|-------------|
|  | [`~PacketTransaction`](#packettransaction-3) `virtual` `inline` |  |
| `void` | [`onStateChange`](#onstatechange-1) `virtual` `inline` `override` | Post state change hook. Calls [dispose()](#dispose) on terminal states to stop the timer, but does not delete the object; [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) handles that. |
| `bool` | [`handlePotentialResponse`](#handlepotentialresponse) `virtual` `inline` | Processes a potential response candidate and updates the state accordingly. |
| `bool` | [`checkResponse`](#checkresponse) `virtual` | Checks a potential response candidate and returns true on successful match. |
| `void` | [`onResponse`](#onresponse) `virtual` `inline` | Called when a successful response is received. |
| `void` | [`onTimeout`](#ontimeout) `virtual` `inline` | Called by the timer when the transaction timeout elapses. Retransmits if retries remain, otherwise transitions to `Failed`. |

---

<a id="packettransaction-3"></a>

### ~PacketTransaction

`virtual` `inline`

```cpp
virtual inline ~PacketTransaction()
```

[Defined in src/base/include/icy/packettransaction.h:167](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L167)

---

<a id="onstatechange-1"></a>

### onStateChange

`virtual` `inline` `override`

```cpp
virtual inline void onStateChange(TransactionState & state, const TransactionState &) override
```

[Defined in src/base/include/icy/packettransaction.h:174](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L174)

Post state change hook. Calls [dispose()](#dispose) on terminal states to stop the timer, but does not delete the object; [IntrusivePtr](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr) handles that.

#### Reimplements

- [`Stateful::onStateChange`](https://auscaster.com/icey/docs/api-reference/icy-Stateful.md#onstatechange-2)

---

<a id="handlepotentialresponse"></a>

### handlePotentialResponse

`virtual` `inline`

```cpp
virtual inline bool handlePotentialResponse(const PacketT & packet)
```

[Defined in src/base/include/icy/packettransaction.h:185](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L185)

Processes a potential response candidate and updates the state accordingly.

---

<a id="checkresponse"></a>

### checkResponse

`virtual`

```cpp
virtual bool checkResponse(const PacketT & packet)
```

[Defined in src/base/include/icy/packettransaction.h:198](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L198)

Checks a potential response candidate and returns true on successful match.

#### Reimplemented by

- [`Transaction::checkResponse`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#checkresponse-1)

---

<a id="onresponse"></a>

### onResponse

`virtual` `inline`

```cpp
virtual inline void onResponse()
```

[Defined in src/base/include/icy/packettransaction.h:201](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L201)

Called when a successful response is received.

#### Reimplemented by

- [`Transaction::onResponse`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#onresponse-1)
- [`Transaction::onResponse`](https://auscaster.com/icey/docs/api-reference/icy-net-Transaction.md#onresponse-1)
- [`Transaction::onResponse`](https://auscaster.com/icey/docs/api-reference/icy-stun-Transaction.md#onresponse-2)

---

<a id="ontimeout"></a>

### onTimeout

`virtual` `inline`

```cpp
virtual inline void onTimeout()
```

[Defined in src/base/include/icy/packettransaction.h:208](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L208)

Called by the timer when the transaction timeout elapses. Retransmits if retries remain, otherwise transitions to `Failed`.

## Public Types

| Name | Description |
|------|-------------|
| [`Ptr`](#ptr-3)  |  |

---

<a id="ptr-3"></a>

### Ptr

```cpp
using Ptr = IntrusivePtr< PacketTransaction< PacketT > >
```

Type: [`IntrusivePtr`](https://auscaster.com/icey/docs/api-reference/icy-IntrusivePtr.md#intrusiveptr)< [`PacketTransaction`](#packettransaction)< PacketT > >

[Defined in src/base/include/icy/packettransaction.h:75](https://github.com/auscaster/icey/blob/main/src/base/include/icy/packettransaction.h#L75)
