Noble Connect
Add relays and punchthrough to Mirror or UNet
NobleConnect.Ice.Session Class Reference

Inherits IDisposable.

Public Types

enum  State { State.NOT_STARTED, State.RUNNING, State.COMPLETED, State.FAILED }
 

Public Member Functions

 Session (Controller controller, bool isControlling)
 
void SendInitialOffer (Action onOfferFailed, IPEndPoint remoteRelayEndPoint)
 
void CreatePermissionForRemoteOnLocalRelay (Action< Stun.Message > onSuccess, Action< Stun.Message > onFail)
 Allows the client's relay to send to and receive from the host's relay More...
 
void CreatePermissionForLocalOnRemoteRelay (Action< Stun.Message > onSuccess, Action< Stun.Message > onFail)
 Allows the host's relay to send and receive from the client's relay. More...
 
void SendOffer (IPEndPoint remoteRelayEndPoint, Action< Transaction< Sdp.Message >> onFail)
 
void BuildCandidatePairList ()
 
bool PerformNextConnectivityCheck ()
 
bool OnReceivedIncomingConnectivityCheck (Stun.Controller receivingStunController, Stun.Message request, IPEndPoint source, IPEndPoint receivedAt)
 
void CheckIfDone ()
 
void Restart ()
 
void HandleRoleConflictFromConnectivityCheckResponse (CandidatePair generatingPair, Transaction< Stun.Message > transaction)
 
bool HandleRoleConflictFromIncomingConnectivityCheck (Stun.Controller stunController, Stun.Message request, IPEndPoint source, IPEndPoint receivedAt)
 
void SendRoleConflictResponse (Stun.Controller stunController, Stun.Message request, IPEndPoint source, IPEndPoint receivedAt)
 
CandidatePair CreateNewCandidatePairIfNecessary (Stun.Controller stunController, Stun.Message request, IPEndPoint remoteEndPoint, IPEndPoint receivedAt)
 
void CleanUp (bool preserveSelectedPair=true)
 Used to clean up unused permissions and channels, or all permissions and channels More...
 
void Dispose ()
 

Public Attributes

Guid localUsernameFragment
 
string remoteUsernameFragment
 
Guid localPassword
 
string remotePassword
 
State state = State.NOT_STARTED
 
List< CandidateremoteCandidates = new List<Candidate>()
 
List< CandidatePaircandidatePairs = new List<CandidatePair>()
 
List< CandidatePairtriggeredCheckQueue = new List<CandidatePair>()
 
CandidatePair defaultCandidatePair
 
List< CandidatePairvalidCandidatePairs = new List<CandidatePair>()
 
IPEndPoint remoteRelayEndPoint
 
bool isControlling
 
ulong tieBreaker
 
CandidatePair selectedPair = null
 
bool isRestarting = false
 
CandidatePair candidatePairToReplaceAfterRestart
 
IPEndPoint remoteDefaultMediaAddress
 

Member Enumeration Documentation

◆ State

Enumerator
NOT_STARTED 
RUNNING 
COMPLETED 
FAILED 

Constructor & Destructor Documentation

◆ Session()

NobleConnect.Ice.Session.Session ( Controller  controller,
bool  isControlling 
)

Member Function Documentation

◆ BuildCandidatePairList()

void NobleConnect.Ice.Session.BuildCandidatePairList ( )

◆ CheckIfDone()

void NobleConnect.Ice.Session.CheckIfDone ( )

◆ CleanUp()

void NobleConnect.Ice.Session.CleanUp ( bool  preserveSelectedPair = true)

Used to clean up unused permissions and channels, or all permissions and channels

The permissions are revoked that were used to send the sip invite and answer Channels are revoked for all candidate pairs (except the selected pair when preserving) Binding refreshes are cancelled for all candidate pairs (except the selected pair when preserving)

◆ CreateNewCandidatePairIfNecessary()

CandidatePair NobleConnect.Ice.Session.CreateNewCandidatePairIfNecessary ( Stun.Controller  stunController,
Stun.Message  request,
IPEndPoint  remoteEndPoint,
IPEndPoint  receivedAt 
)

◆ CreatePermissionForLocalOnRemoteRelay()

void NobleConnect.Ice.Session.CreatePermissionForLocalOnRemoteRelay ( Action< Stun.Message onSuccess,
Action< Stun.Message onFail 
)

Allows the host's relay to send and receive from the client's relay.

The request is sent over the client's relay. This is because the client may not be able to directly communicate with the host's turn server This would be the case if the client is ipv4 and the hostRelayEndPoint is ipv6 or vice versa. The dual stack relays bridge the gap. Note that address family matters for peers. We must create a permission for the client relay address that has the same address family as the host relay address. If we use the wrong address then the host relay would see the invite as coming from a different address than the one we add permission for here and it will be rejected.

◆ CreatePermissionForRemoteOnLocalRelay()

void NobleConnect.Ice.Session.CreatePermissionForRemoteOnLocalRelay ( Action< Stun.Message onSuccess,
Action< Stun.Message onFail 
)

Allows the client's relay to send to and receive from the host's relay

Note that address family matters for peers, so for dual stack relays the host will only be able to send a return message if it is targeted at the same address family as the hostRelayEndPoint. For example if the hostRelayEndPoint is an ipv4 address, and the host tries to send to a client's ipv6 relay address, it will appear to come from the host's ipv6 relay address instead of the ipv4 address that we created a permission for, so it will be rejected. Essentially what this means is that when a client sends a sip invite, the default media address has to be the same family as the hostRelayEndPoint so that when the host sends a return message it will come from the correct host relay address.

◆ Dispose()

void NobleConnect.Ice.Session.Dispose ( )

◆ HandleRoleConflictFromConnectivityCheckResponse()

void NobleConnect.Ice.Session.HandleRoleConflictFromConnectivityCheckResponse ( CandidatePair  generatingPair,
Transaction< Stun.Message transaction 
)

◆ HandleRoleConflictFromIncomingConnectivityCheck()

bool NobleConnect.Ice.Session.HandleRoleConflictFromIncomingConnectivityCheck ( Stun.Controller  stunController,
Stun.Message  request,
IPEndPoint  source,
IPEndPoint  receivedAt 
)

◆ OnReceivedIncomingConnectivityCheck()

bool NobleConnect.Ice.Session.OnReceivedIncomingConnectivityCheck ( Stun.Controller  receivingStunController,
Stun.Message  request,
IPEndPoint  source,
IPEndPoint  receivedAt 
)

◆ PerformNextConnectivityCheck()

bool NobleConnect.Ice.Session.PerformNextConnectivityCheck ( )

◆ Restart()

void NobleConnect.Ice.Session.Restart ( )

◆ SendInitialOffer()

void NobleConnect.Ice.Session.SendInitialOffer ( Action  onOfferFailed,
IPEndPoint  remoteRelayEndPoint 
)

◆ SendOffer()

void NobleConnect.Ice.Session.SendOffer ( IPEndPoint  remoteRelayEndPoint,
Action< Transaction< Sdp.Message >>  onFail 
)

◆ SendRoleConflictResponse()

void NobleConnect.Ice.Session.SendRoleConflictResponse ( Stun.Controller  stunController,
Stun.Message  request,
IPEndPoint  source,
IPEndPoint  receivedAt 
)

Member Data Documentation

◆ candidatePairs

List<CandidatePair> NobleConnect.Ice.Session.candidatePairs = new List<CandidatePair>()

◆ candidatePairToReplaceAfterRestart

CandidatePair NobleConnect.Ice.Session.candidatePairToReplaceAfterRestart

◆ defaultCandidatePair

CandidatePair NobleConnect.Ice.Session.defaultCandidatePair

◆ isControlling

bool NobleConnect.Ice.Session.isControlling

◆ isRestarting

bool NobleConnect.Ice.Session.isRestarting = false

◆ localPassword

Guid NobleConnect.Ice.Session.localPassword

◆ localUsernameFragment

Guid NobleConnect.Ice.Session.localUsernameFragment

◆ remoteCandidates

List<Candidate> NobleConnect.Ice.Session.remoteCandidates = new List<Candidate>()

◆ remoteDefaultMediaAddress

IPEndPoint NobleConnect.Ice.Session.remoteDefaultMediaAddress

◆ remotePassword

string NobleConnect.Ice.Session.remotePassword

◆ remoteRelayEndPoint

IPEndPoint NobleConnect.Ice.Session.remoteRelayEndPoint

◆ remoteUsernameFragment

string NobleConnect.Ice.Session.remoteUsernameFragment

◆ selectedPair

CandidatePair NobleConnect.Ice.Session.selectedPair = null

◆ state

State NobleConnect.Ice.Session.state = State.NOT_STARTED

◆ tieBreaker

ulong NobleConnect.Ice.Session.tieBreaker

◆ triggeredCheckQueue

List<CandidatePair> NobleConnect.Ice.Session.triggeredCheckQueue = new List<CandidatePair>()

◆ validCandidatePairs

List<CandidatePair> NobleConnect.Ice.Session.validCandidatePairs = new List<CandidatePair>()