Temporary workaround for clients not able to handle combined updates (#777)
See: https://github.com/livekit/client-sdk-js/pull/275
This commit is contained in:
+4
-1
@@ -849,6 +849,7 @@ func (r *Room) pushAndDequeueUpdates(pi *livekit.ParticipantInfo, isImmediate bo
|
|||||||
var updates []*livekit.ParticipantInfo
|
var updates []*livekit.ParticipantInfo
|
||||||
identity := livekit.ParticipantIdentity(pi.Identity)
|
identity := livekit.ParticipantIdentity(pi.Identity)
|
||||||
existing := r.batchedUpdates[identity]
|
existing := r.batchedUpdates[identity]
|
||||||
|
shouldSend := isImmediate || pi.IsPublisher
|
||||||
|
|
||||||
if existing != nil {
|
if existing != nil {
|
||||||
if pi.Sid != existing.Sid {
|
if pi.Sid != existing.Sid {
|
||||||
@@ -859,10 +860,12 @@ func (r *Room) pushAndDequeueUpdates(pi *livekit.ParticipantInfo, isImmediate bo
|
|||||||
} else if pi.Version < existing.Version {
|
} else if pi.Version < existing.Version {
|
||||||
// out of order update
|
// out of order update
|
||||||
return nil
|
return nil
|
||||||
|
} else if shouldSend {
|
||||||
|
updates = append(updates, existing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isImmediate || pi.IsPublisher {
|
if shouldSend {
|
||||||
// include any queued update, and return
|
// include any queued update, and return
|
||||||
delete(r.batchedUpdates, identity)
|
delete(r.batchedUpdates, identity)
|
||||||
updates = append(updates, pi)
|
updates = append(updates, pi)
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ func TestPushAndDequeueUpdates(t *testing.T) {
|
|||||||
name: "when switching to publisher, queue is cleared",
|
name: "when switching to publisher, queue is cleared",
|
||||||
pi: publisher1v2,
|
pi: publisher1v2,
|
||||||
existing: subscriber1v1,
|
existing: subscriber1v1,
|
||||||
expected: []*livekit.ParticipantInfo{publisher1v2},
|
expected: []*livekit.ParticipantInfo{subscriber1v1, publisher1v2},
|
||||||
validate: func(t *testing.T, rm *Room, updates []*livekit.ParticipantInfo) {
|
validate: func(t *testing.T, rm *Room, updates []*livekit.ParticipantInfo) {
|
||||||
require.Empty(t, rm.batchedUpdates)
|
require.Empty(t, rm.batchedUpdates)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user