From 372175cca47c3ecac9d9d72c47630dec709a8b3d Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Thu, 1 Aug 2019 17:35:48 -0700 Subject: [PATCH] Do connectivity check when candidate is added When trickle is enabled do a connectivity check everytime a candidate is added. Because we have a new candidate there is a chance we could have a success this time. --- agent.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/agent.go b/agent.go index a36423e..d6d68c1 100644 --- a/agent.go +++ b/agent.go @@ -461,7 +461,7 @@ func (a *Agent) startConnectivityChecks(isControlling bool, remoteUfrag, remoteP agent.updateConnectionState(ConnectionStateChecking) // TODO this should be dynamic, and grow when the connection is stable - agent.forceCandidateContact <- true + a.requestConnectivityCheck() agent.connectivityTicker = time.NewTicker(a.taskLoopInterval) }) } @@ -691,6 +691,13 @@ func (a *Agent) resolveAndAddMulticastCandidate(c *CandidateHost) { } } +func (a *Agent) requestConnectivityCheck() { + select { + case a.forceCandidateContact <- true: + default: + } +} + // addRemoteCandidate assumes you are holding the lock (must be execute using a.run) func (a *Agent) addRemoteCandidate(c Candidate) { set := a.remoteCandidates[c.NetworkType()] @@ -709,6 +716,8 @@ func (a *Agent) addRemoteCandidate(c Candidate) { a.addPair(localCandidate, c) } } + + a.requestConnectivityCheck() } // addCandidate assumes you are holding the lock (must be execute using a.run)