commit 5380aaca8c1c789fa4f692e93dfdc4e59d4992af Author: Arlo Breault arlolra@gmail.com Date: Tue May 14 16:48:01 2019 -0400
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.