From b4ea4de5c07346e9a10c3f2c240a5ffe80220d24 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 24 Apr 2023 15:24:50 -0700 Subject: [PATCH] Skip room updates to participants unless they are active --- pkg/rtc/room.go | 6 ++++-- pkg/rtc/room_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/rtc/room.go b/pkg/rtc/room.go index 7c789cba4..ba5d5db44 100644 --- a/pkg/rtc/room.go +++ b/pkg/rtc/room.go @@ -417,7 +417,7 @@ func (r *Room) ResumeParticipant(p types.LocalParticipant, requestSource routing return err } - p.SendRoomUpdate(r.ToProto()) + _ = p.SendRoomUpdate(r.ToProto()) p.ICERestart(nil) return nil } @@ -667,7 +667,9 @@ func (r *Room) sendRoomUpdate() { roomInfo := r.ToProto() // Send update to participants for _, p := range r.GetParticipants() { - if !p.IsReady() { + // new participants receive the update as part of JoinResponse + // skip inactive participants + if p.State() != livekit.ParticipantInfo_ACTIVE { continue } diff --git a/pkg/rtc/room_test.go b/pkg/rtc/room_test.go index 80987785a..35cc3caa9 100644 --- a/pkg/rtc/room_test.go +++ b/pkg/rtc/room_test.go @@ -678,7 +678,7 @@ func TestRoomUpdate(t *testing.T) { // p1 should have received an update time.Sleep(2 * defaultDelay) - require.GreaterOrEqual(t, p1.SendRoomUpdateCallCount(), 1) + require.Equal(t, 1, p1.SendRoomUpdateCallCount()) require.EqualValues(t, 2, p1.SendRoomUpdateArgsForCall(p1.SendRoomUpdateCallCount()-1).NumParticipants) })