@@ -80,8 +80,8 @@ func newWithClientOrServer(servers []webrtc.ICEServer, client bool, opts *ConnOp
80
80
// of this will cause a connection failure.
81
81
localCandidateChannel : make (chan webrtc.ICECandidateInit , 16 ),
82
82
pendingCandidates : make ([]webrtc.ICECandidateInit , 0 ),
83
- localSessionDescriptionChannel : make (chan webrtc.SessionDescription , 1 ),
84
- remoteSessionDescriptionChannel : make (chan webrtc.SessionDescription , 1 ),
83
+ localSessionDescriptionChannel : make (chan webrtc.SessionDescription ),
84
+ remoteSessionDescriptionChannel : make (chan webrtc.SessionDescription ),
85
85
}
86
86
if client {
87
87
// If we're the client, we want to flip the echo and
@@ -357,10 +357,6 @@ func (c *Conn) negotiate() {
357
357
return
358
358
}
359
359
360
- if c .offerrer {
361
- c .flushPendingCandidates ()
362
- }
363
-
364
360
if ! c .offerrer {
365
361
answer , err := c .rtc .CreateAnswer (& webrtc.AnswerOptions {})
366
362
if err != nil {
@@ -384,12 +380,8 @@ func (c *Conn) negotiate() {
384
380
return
385
381
case c .localSessionDescriptionChannel <- answer :
386
382
}
387
-
388
- c .flushPendingCandidates ()
389
383
}
390
- }
391
384
392
- func (c * Conn ) flushPendingCandidates () {
393
385
c .pendingCandidatesMutex .Lock ()
394
386
defer c .pendingCandidatesMutex .Unlock ()
395
387
for _ , pendingCandidate := range c .pendingCandidates {
@@ -421,6 +413,8 @@ func (c *Conn) AddRemoteCandidate(i webrtc.ICECandidateInit) error {
421
413
slog .F ("hash" , c .hashCandidate (i )),
422
414
slog .F ("length" , len (i .Candidate )),
423
415
)
416
+ c .closeMutex .Lock ()
417
+ defer c .closeMutex .Unlock ()
424
418
return c .rtc .AddICECandidate (i )
425
419
}
426
420
0 commit comments