Noble Connect
Add relays and punchthrough to Mirror or UNet
NobleConnect.Transaction< T > Class Template Reference

Transactions are used to track Stun requests and correletate them with responses More...

Inherits IDisposable.

Public Member Functions

 Transaction (Stun.Controller owner, IPEndPoint source, IPEndPoint destination, T request, Action< Transaction< T >> onSuccess=null, Action< Transaction< T >> onTimeout=null, Action< Transaction< T >> onFail=null, int retransmissionTimeout=-1, int maxRetransmissions=3)
 Construct a new transaction for the provided request Message and onComplete action More...
 
int RoundTripTime ()
 
void StartTimeout ()
 
void Cancel ()
 
void Complete (T response, IPEndPoint source, IPEndPoint destination, bool success=true)
 
void Dispose ()
 

Public Attributes

readonly Action< Transaction< T > > onComplete
 The action to call when the request receives a response More...
 
readonly Action< Transaction< T > > onFail
 
readonly Action< Transaction< T > > onTimeout
 
readonly T request
 The request Message that started this Transaction More...
 
readonly int maxRetransmissions = 2
 
readonly Stun.Controller owner
 
IPEndPoint associatedAllocation
 

Protected Member Functions

virtual void Dispose (bool disposing)
 

Properties

IPEndPoint RequestSource [get]
 
IPEndPoint RequestDestination [get]
 
IPEndPoint ResponseSource [get]
 
IPEndPoint ResponseDestination [get]
 
Response [get]
 
bool IsComplete [get]
 

Detailed Description

Transactions are used to track Stun requests and correletate them with responses

When a request Message is sent, a Transaction is created that stores the original request Message as well as an onComplete action to be called when the response is received. When a response is received, the response Message is passed to the onComplete action so that the application can make use of it.

Type Constraints
T :IMessage 

Constructor & Destructor Documentation

◆ Transaction()

NobleConnect.Transaction< T >.Transaction ( Stun.Controller  owner,
IPEndPoint  source,
IPEndPoint  destination,
request,
Action< Transaction< T >>  onSuccess = null,
Action< Transaction< T >>  onTimeout = null,
Action< Transaction< T >>  onFail = null,
int  retransmissionTimeout = -1,
int  maxRetransmissions = 3 
)

Construct a new transaction for the provided request Message and onComplete action

Parameters
request
onSuccess

Member Function Documentation

◆ Cancel()

void NobleConnect.Transaction< T >.Cancel ( )

◆ Complete()

void NobleConnect.Transaction< T >.Complete ( response,
IPEndPoint  source,
IPEndPoint  destination,
bool  success = true 
)

◆ Dispose() [1/2]

void NobleConnect.Transaction< T >.Dispose ( )

◆ Dispose() [2/2]

virtual void NobleConnect.Transaction< T >.Dispose ( bool  disposing)
protectedvirtual

◆ RoundTripTime()

int NobleConnect.Transaction< T >.RoundTripTime ( )

◆ StartTimeout()

void NobleConnect.Transaction< T >.StartTimeout ( )

Member Data Documentation

◆ associatedAllocation

IPEndPoint NobleConnect.Transaction< T >.associatedAllocation

◆ maxRetransmissions

readonly int NobleConnect.Transaction< T >.maxRetransmissions = 2

◆ onComplete

readonly Action<Transaction<T> > NobleConnect.Transaction< T >.onComplete

The action to call when the request receives a response

◆ onFail

readonly Action<Transaction<T> > NobleConnect.Transaction< T >.onFail

◆ onTimeout

readonly Action<Transaction<T> > NobleConnect.Transaction< T >.onTimeout

◆ owner

◆ request

readonly T NobleConnect.Transaction< T >.request

The request Message that started this Transaction

Property Documentation

◆ IsComplete

bool NobleConnect.Transaction< T >.IsComplete
get

◆ RequestDestination

IPEndPoint NobleConnect.Transaction< T >.RequestDestination
get

◆ RequestSource

IPEndPoint NobleConnect.Transaction< T >.RequestSource
get

◆ Response

T NobleConnect.Transaction< T >.Response
get

◆ ResponseDestination

IPEndPoint NobleConnect.Transaction< T >.ResponseDestination
get

◆ ResponseSource

IPEndPoint NobleConnect.Transaction< T >.ResponseSource
get