STUN module (rfc5389)

Transaction

STUN request/response transaction with timeout and retry logic.

Transaction

#include <icy/stun/transaction.h>

Inherits: Transaction< Message >

STUN request/response transaction with timeout and retry logic. Extends the generic net::Transaction with STUN-specific transaction ID matching and response class inference (Success, Error, or Indication).

Lifetime is managed by IntrusivePtr. Create via makeIntrusive or wrap in IntrusivePtr immediately after construction.

Public Methods

ReturnNameDescription
TransactionConstructs a STUN transaction bound to a specific socket and peer.
boolcheckResponseChecks that message is a valid response for the pending request. In addition to the base class check, verifies that the transaction IDs match.
voidonResponse virtualCalled when a valid response is received. Infers the response class (SuccessResponse, ErrorResponse, or Indication) from the response attributes and delegates to the base class handler.

Transaction

Transaction(const net::Socket::Ptr & socket, const net::Address & peerAddress, long timeout, int retries)

Constructs a STUN transaction bound to a specific socket and peer.

Parameters

  • socket Socket used to send the request and receive the response.

  • peerAddress Remote address of the STUN/TURN server.

  • timeout Response timeout in milliseconds (default 10 s).

  • retries Number of send retries before declaring failure (default 1).


checkResponse

bool checkResponse(const Message & message)

Checks that message is a valid response for the pending request. In addition to the base class check, verifies that the transaction IDs match.

Parameters

  • message Incoming STUN message to evaluate.

Returns

true if message is the expected response.


onResponse

virtual

virtual void onResponse()

Called when a valid response is received. Infers the response class (SuccessResponse, ErrorResponse, or Indication) from the response attributes and delegates to the base class handler.

Public Types

NameDescription
Ptr

Ptr

IntrusivePtr< Transaction > Ptr()