Send self participant update immediately. (#3656)
* Send self participant update immediately. Match with cloud. Send immediately for non-hidden participants also * comment
This commit is contained in:
+15
-2
@@ -1337,20 +1337,33 @@ func (r *Room) subscribeToExistingTracks(p types.LocalParticipant) {
|
|||||||
func (r *Room) broadcastParticipantState(p types.LocalParticipant, opts broadcastOptions) {
|
func (r *Room) broadcastParticipantState(p types.LocalParticipant, opts broadcastOptions) {
|
||||||
pi := p.ToProto()
|
pi := p.ToProto()
|
||||||
|
|
||||||
if p.Hidden() {
|
// send it to the same participant immediately
|
||||||
|
selfSent := false
|
||||||
if !opts.skipSource {
|
if !opts.skipSource {
|
||||||
// send update only to hidden participant
|
defer func() {
|
||||||
|
if selfSent {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err := p.SendParticipantUpdate([]*livekit.ParticipantInfo{pi})
|
err := p.SendParticipantUpdate([]*livekit.ParticipantInfo{pi})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.GetLogger().Errorw("could not send update to participant", err)
|
p.GetLogger().Errorw("could not send update to participant", err)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Hidden() {
|
||||||
|
// hidden participant updates are sent only to the hidden participant itself,
|
||||||
|
// these could be things like metadata update
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
updates := r.pushAndDequeueUpdates(pi, p.CloseReason(), opts.immediate)
|
updates := r.pushAndDequeueUpdates(pi, p.CloseReason(), opts.immediate)
|
||||||
|
if len(updates) != 0 {
|
||||||
|
selfSent = true
|
||||||
r.sendParticipantUpdates(updates)
|
r.sendParticipantUpdates(updates)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Room) sendParticipantUpdates(updates []*participantUpdate) {
|
func (r *Room) sendParticipantUpdates(updates []*participantUpdate) {
|
||||||
if len(updates) == 0 {
|
if len(updates) == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user