From 5380aaca8c1c789fa4f692e93dfdc4e59d4992af Mon Sep 17 00:00:00 2001 From: Arlo Breault Date: Tue, 14 May 2019 16:48:01 -0400 Subject: [PATCH] Use OnIceGatheringStateChange instead of OnIceComplete in client Amounts to the same thing as currently implemented in go-webrtc --- client/lib/webrtc.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go index 71c96ab..6406da5 100644 --- a/client/lib/webrtc.go +++ b/client/lib/webrtc.go @@ -176,14 +176,15 @@ func (c *WebRTCPeer) preparePeerConnection() error { } }() } - // Allow candidates to accumulate until OnIceComplete. + // Allow candidates to accumulate until IceGatheringStateComplete. pc.OnIceCandidate = func(candidate webrtc.IceCandidate) { log.Printf(candidate.Candidate) } - // TODO: This may soon be deprecated, consider OnIceGatheringStateChange. - pc.OnIceComplete = func() { - log.Printf("WebRTC: OnIceComplete") - c.offerChannel <- pc.LocalDescription() + pc.OnIceGatheringStateChange = func(state webrtc.IceGatheringState) { + if state == webrtc.IceGatheringStateComplete { + log.Printf("WebRTC: IceGatheringStateComplete") + c.offerChannel <- pc.LocalDescription() + } } // This callback is not expected, as the Client initiates the creation // of the data channel, not the remote peer.