From 5371f4466ad4dfadd3a87133e5df9103998c001a Mon Sep 17 00:00:00 2001 From: aoife cassidy Date: Fri, 5 Jul 2024 19:23:52 -0700 Subject: [PATCH] room: allow RemoteParticipant to be None --- livekit-rtc/livekit/rtc/room.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/livekit-rtc/livekit/rtc/room.py b/livekit-rtc/livekit/rtc/room.py index 2221eb41..27efd64f 100644 --- a/livekit-rtc/livekit/rtc/room.py +++ b/livekit-rtc/livekit/rtc/room.py @@ -446,16 +446,16 @@ def _on_room_event(self, event: proto_room.RoomEvent): def _retrieve_remote_participant( self, sid: str, identity: str - ) -> RemoteParticipant: + ) -> Optional[RemoteParticipant]: """Retrieve a remote participant by sid or identity""" participant = None if identity: participant = self.participants_by_identity[identity] - if not participant: + if not participant and sid in self.participants: participant = self.participants[sid] return participant - def _retrieve_participant(self, sid: str, identity: str) -> Participant: + def _retrieve_participant(self, sid: str, identity: str) -> Optional[Participant]: """Retrieve a participant by sid or identity, returns the LocalParticipant if sid or identity matches""" if identity and identity == self.local_participant.identity: