Ensure older participant session update does not go out after a newer (#1372)
* Ensure older participant session update does not go out after a newer session has joined. * fix tests * change comment * do not send older version
This commit is contained in:
+17
-1
@@ -211,28 +211,33 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
Sid: "1",
|
||||
IsPublisher: true,
|
||||
Version: 1,
|
||||
JoinedAt: 0,
|
||||
}
|
||||
publisher1v2 := &livekit.ParticipantInfo{
|
||||
Identity: identity,
|
||||
Sid: "1",
|
||||
IsPublisher: true,
|
||||
Version: 2,
|
||||
JoinedAt: 1,
|
||||
}
|
||||
publisher2 := &livekit.ParticipantInfo{
|
||||
Identity: identity,
|
||||
Sid: "2",
|
||||
IsPublisher: true,
|
||||
Version: 1,
|
||||
JoinedAt: 2,
|
||||
}
|
||||
subscriber1v1 := &livekit.ParticipantInfo{
|
||||
Identity: identity,
|
||||
Sid: "1",
|
||||
Version: 1,
|
||||
JoinedAt: 0,
|
||||
}
|
||||
subscriber1v2 := &livekit.ParticipantInfo{
|
||||
Identity: identity,
|
||||
Sid: "1",
|
||||
Version: 2,
|
||||
JoinedAt: 1,
|
||||
}
|
||||
|
||||
requirePIEquals := func(t *testing.T, a, b *livekit.ParticipantInfo) {
|
||||
@@ -267,6 +272,17 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
requirePIEquals(t, subscriber1v2, queued)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "both versions updates when immediate",
|
||||
pi: subscriber1v2,
|
||||
existing: subscriber1v1,
|
||||
immediate: true,
|
||||
expected: []*livekit.ParticipantInfo{subscriber1v2},
|
||||
validate: func(t *testing.T, rm *Room, _ []*livekit.ParticipantInfo) {
|
||||
queued := rm.batchedUpdates[livekit.ParticipantIdentity(identity)]
|
||||
require.Nil(t, queued)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "out of order updates are rejected",
|
||||
pi: subscriber1v1,
|
||||
@@ -294,7 +310,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
||||
name: "when switching to publisher, queue is cleared",
|
||||
pi: publisher1v2,
|
||||
existing: subscriber1v1,
|
||||
expected: []*livekit.ParticipantInfo{subscriber1v1, publisher1v2},
|
||||
expected: []*livekit.ParticipantInfo{publisher1v2},
|
||||
validate: func(t *testing.T, rm *Room, updates []*livekit.ParticipantInfo) {
|
||||
require.Empty(t, rm.batchedUpdates)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user