Skip to content

Commit

Permalink
add assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp committed Jul 6, 2024
1 parent 5371f44 commit dc46623
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion livekit-rtc/livekit/rtc/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
sid = event.track_muted.participant_sid
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
assert isinstance(participant, Participant)
publication = participant.tracks[event.track_muted.track_sid]
publication._info.muted = True
if publication.track:
Expand All @@ -339,6 +340,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
sid = event.track_unmuted.participant_sid
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
assert isinstance(participant, Participant)
publication = participant.tracks[event.track_unmuted.track_sid]
publication._info.muted = False
if publication.track:
Expand All @@ -349,7 +351,9 @@ def _on_room_event(self, event: proto_room.RoomEvent):
speakers: list[Participant] = []
# TODO: pass participant identity
for sid in event.active_speakers_changed.participant_sids:
speakers.append(self._retrieve_participant(sid, ""))
participant = self._retrieve_participant(sid, "")
assert isinstance(participant, Participant)
speakers.append(participant)

self.emit("active_speakers_changed", speakers)
elif which == "room_metadata_changed":
Expand All @@ -360,6 +364,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
sid = event.participant_metadata_changed.participant_sid
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
assert isinstance(participant, Participant)
old_metadata = participant.metadata
participant._info.metadata = event.participant_metadata_changed.metadata
self.emit(
Expand All @@ -372,6 +377,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
sid = event.participant_name_changed.participant_sid
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
assert isinstance(participant, Participant)
old_name = participant.name
participant._info.name = event.participant_name_changed.name
self.emit(
Expand Down Expand Up @@ -402,6 +408,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
rparticipant = self._retrieve_remote_participant(
packet.participant_sid, packet.participant_identity
)
assert isinstance(rparticipant, RemoteParticipant)
self.emit(
"data_received",
DataPacket(
Expand All @@ -415,6 +422,7 @@ def _on_room_event(self, event: proto_room.RoomEvent):
rparticipant = self._retrieve_remote_participant(
packet.participant_sid, packet.participant_identity
)
assert isinstance(rparticipant, RemoteParticipant)
self.emit(
"sip_dtmf_received",
SipDTMF(
Expand Down

0 comments on commit dc46623

Please sign in to comment.