mirror of
https://github.com/netbirdio/ice.git
synced 2026-05-22 17:10:58 -07:00
Flush state change/candidate callback
After closing the channels.
This commit is contained in:
committed by
Sean DuBois
parent
caa80e3027
commit
84957eb8da
@@ -319,27 +319,39 @@ func (a *Agent) onSelectedCandidatePairChange(p *candidatePair) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Agent) onCandidate(c Candidate) {
|
||||
if onCandidateHdlr, ok := a.onCandidateHdlr.Load().(func(Candidate)); ok {
|
||||
onCandidateHdlr(c)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Agent) onConnectionStateChange(s ConnectionState) {
|
||||
if hdlr, ok := a.onConnectionStateChangeHdlr.Load().(func(ConnectionState)); ok {
|
||||
hdlr(s)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Agent) startOnConnectionStateChangeRoutine() {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case s, isOpen := <-a.chanState:
|
||||
if !isOpen {
|
||||
for c := range a.chanCandidate {
|
||||
a.onCandidate(c)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if hdlr, ok := a.onConnectionStateChangeHdlr.Load().(func(ConnectionState)); ok {
|
||||
hdlr(s)
|
||||
}
|
||||
a.onConnectionStateChange(s)
|
||||
|
||||
case c, isOpen := <-a.chanCandidate:
|
||||
if !isOpen {
|
||||
for s := range a.chanState {
|
||||
a.onConnectionStateChange(s)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if onCandidateHdlr, ok := a.onCandidateHdlr.Load().(func(Candidate)); ok {
|
||||
onCandidateHdlr(c)
|
||||
}
|
||||
a.onCandidate(c)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user