diff --git a/examples/ping-pong/main.go b/examples/ping-pong/main.go index 0229f877..af02a793 100644 --- a/examples/ping-pong/main.go +++ b/examples/ping-pong/main.go @@ -47,8 +47,10 @@ func remoteCandidate(_ http.ResponseWriter, r *http.Request) { panic(err) } - if err := iceAgent.AddRemoteCandidate(c); err != nil { //nolint:contextcheck - panic(err) + if c != nil { + if err := iceAgent.AddRemoteCandidate(c); err != nil { //nolint:contextcheck + panic(err) + } } } @@ -70,6 +72,11 @@ func main() { //nolint remoteHTTPPort = 9000 } + iceAgent, err = ice.NewAgent() + if err != nil { + panic(err) + } + http.HandleFunc("/remoteAuth", remoteAuth) http.HandleFunc("/remoteCandidate", remoteCandidate) go func() { @@ -88,11 +95,6 @@ func main() { //nolint panic(err) } - iceAgent, err = ice.NewAgent() - if err != nil { - panic(err) - } - // When we have gathered a new ICE Candidate send it to the remote peer if err = iceAgent.OnCandidate(func(c ice.Candidate) { if c == nil {