Cache data synchronously for processing in worker. (#2424)
It is possible that state of underlying object has changed between event posting and event processing. So, cache data synchronously and use it during event processing. This is still not perfect as things like `hidden` and `IsClosed` is accessed in worker. Ideally, it can be a snapshot of current state of all required values that can be posted to the worker and the worker just operates with data.
This commit is contained in:
@@ -577,10 +577,10 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room
|
||||
}
|
||||
})
|
||||
|
||||
newRoom.OnParticipantChanged(func(p types.LocalParticipant) {
|
||||
if !p.IsDisconnected() {
|
||||
if err := r.roomStore.StoreParticipant(ctx, roomName, p.ToProto()); err != nil {
|
||||
newRoom.Logger.Errorw("could not handle participant change", err)
|
||||
newRoom.OnParticipantChanged(func(p types.LocalParticipant, pi *livekit.ParticipantInfo) {
|
||||
if pi.State != livekit.ParticipantInfo_DISCONNECTED {
|
||||
if err := r.roomStore.StoreParticipant(ctx, roomName, pi); err != nil {
|
||||
p.GetLogger().Errorw("could not handle participant change", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user