Handle non-primary peerconnection if/when it becomes disconnected (#537)

* Handle non-primary peerconnection if/when it becomes disconnected

* avoid storing nil
This commit is contained in:
David Zhao
2022-03-19 00:31:45 -07:00
committed by GitHub
parent 224dfe68b1
commit 2155405736
2 changed files with 44 additions and 31 deletions
-19
View File
@@ -6,7 +6,6 @@ import (
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
"github.com/pion/webrtc/v3"
"github.com/stretchr/testify/require"
"github.com/livekit/livekit-server/pkg/config"
@@ -49,24 +48,6 @@ func TestIsReady(t *testing.T) {
}
}
func TestICEStateChange(t *testing.T) {
t.Run("onClose gets called when ICE disconnected", func(t *testing.T) {
p := newParticipantForTest("test")
closeChan := make(chan struct{})
p.onClose = func(participant types.LocalParticipant, disallowedSubscriptions map[livekit.TrackID]livekit.ParticipantID) {
close(closeChan)
}
p.handlePrimaryStateChange(webrtc.PeerConnectionStateFailed)
select {
case <-closeChan:
return
case <-time.After(time.Millisecond * 10):
t.Fatalf("onClose was not called after timeout")
}
})
}
func TestTrackPublishing(t *testing.T) {
t.Run("should send the correct events", func(t *testing.T) {
p := newParticipantForTest("test")