Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ func (pc *PeerConnection) OnICECandidate(f func(*ICECandidate)) {
func (pc *PeerConnection) OnICEGatheringStateChange(f func(ICEGatheringState)) {
pc.iceGatherer.OnStateChange(
func(gathererState ICEGathererState) {
if pc.isClosed.Load() {
return
}
switch gathererState {
case ICEGathererStateGathering:
f(ICEGatheringStateGathering)
Expand Down
16 changes: 16 additions & 0 deletions peerconnection_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,19 @@ func TestPeerConnection_GracefulCloseConcurrent(t *testing.T) {
})
}
}

func TestPeerConnection_Close_NoICEGatheringStateChange(t *testing.T) {
pc, err := NewPeerConnection(Configuration{})
assert.NoError(t, err)

var events []ICEGatheringState
pc.OnICEGatheringStateChange(func(state ICEGatheringState) {
events = append(events, state)
})

pc.iceGatherer.setState(ICEGathererStateGathering)
assert.NoError(t, pc.Close())
pc.iceGatherer.setState(ICEGathererStateComplete)

assert.Equal(t, []ICEGatheringState{ICEGatheringStateGathering}, events)
}
Loading