Skip to content

Commit 7c89762

Browse files
scorpionknifesSean-Der
authored andcommitted
Accept nil Candidate in AddRemoteCandidate
Allow a user to pass a nil Candidate. We perform no actions off of this currently. Until browsers implement end-of-candidates consistently it isn't something we can do. Relates to pion/webrtc#1212 and #271
1 parent 5e5f171 commit 7c89762

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

agent.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,11 @@ func (a *Agent) checkKeepalive() {
706706

707707
// AddRemoteCandidate adds a new remote candidate
708708
func (a *Agent) AddRemoteCandidate(c Candidate) error {
709-
// canot check for network yet because it might not be applied
709+
if c == nil {
710+
return nil
711+
}
712+
713+
// cannot check for network yet because it might not be applied
710714
// when mDNS hostame is used.
711715
if c.TCPType() == TCPTypeActive {
712716
// TCP Candidates with tcptype active will probe server passive ones, so

agent_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,3 +1686,11 @@ func TestLiteLifecycle(t *testing.T) {
16861686
<-bFailed
16871687
assert.NoError(t, bAgent.Close())
16881688
}
1689+
1690+
func TestNilCandidate(t *testing.T) {
1691+
a, err := NewAgent(&AgentConfig{})
1692+
assert.NoError(t, err)
1693+
1694+
assert.NoError(t, a.AddRemoteCandidate(nil))
1695+
assert.NoError(t, a.Close())
1696+
}

0 commit comments

Comments
 (0)