1515from __future__ import annotations
1616
1717import ctypes
18- from typing import List , Union
18+ from typing import List , Mapping , Union
19+ from abc import abstractmethod , ABC
1920
2021from ._ffi_client import FfiClient , FfiHandle
2122from ._proto import ffi_pb2 as proto_ffi
@@ -61,18 +62,18 @@ def __init__(self, message: str) -> None:
6162 self .message = message
6263
6364
64- class Participant :
65+ class Participant ( ABC ) :
6566 def __init__ (self , owned_info : proto_participant .OwnedParticipant ) -> None :
6667 self ._info = owned_info .info
6768 self ._ffi_handle = FfiHandle (owned_info .handle .id )
68- self ._track_publications : dict [str , TrackPublication ] = {}
6969
7070 @property
71- def track_publications (self ) -> dict [str , TrackPublication ]:
71+ @abstractmethod
72+ def track_publications (self ) -> Mapping [str , TrackPublication ]:
7273 """
7374 A dictionary of track publications associated with the participant.
7475 """
75- return self . _track_publications
76+ ...
7677
7778 @property
7879 def sid (self ) -> str :
@@ -111,7 +112,14 @@ def __init__(
111112 ) -> None :
112113 super ().__init__ (owned_info )
113114 self ._room_queue = room_queue
114- self .track_publications : dict [str , LocalTrackPublication ] = {} # type: ignore
115+ self ._track_publications : dict [str , LocalTrackPublication ] = {} # type: ignore
116+
117+ @property
118+ def track_publications (self ) -> Mapping [str , LocalTrackPublication ]:
119+ """
120+ A dictionary of track publications associated with the participant.
121+ """
122+ return self ._track_publications
115123
116124 async def publish_data (
117125 self ,
@@ -330,7 +338,7 @@ async def publish_track(
330338 track_publication = LocalTrackPublication (cb .publish_track .publication )
331339 track_publication .track = track
332340 track ._info .sid = track_publication .sid
333- self .track_publications [track_publication .sid ] = track_publication
341+ self ._track_publications [track_publication .sid ] = track_publication
334342
335343 queue .task_done ()
336344 return track_publication
@@ -361,7 +369,7 @@ async def unpublish_track(self, track_sid: str) -> None:
361369 if cb .unpublish_track .error :
362370 raise UnpublishTrackError (cb .unpublish_track .error )
363371
364- publication = self .track_publications .pop (track_sid )
372+ publication = self ._track_publications .pop (track_sid )
365373 publication .track = None
366374 queue .task_done ()
367375 finally :
@@ -374,7 +382,14 @@ def __repr__(self) -> str:
374382class RemoteParticipant (Participant ):
375383 def __init__ (self , owned_info : proto_participant .OwnedParticipant ) -> None :
376384 super ().__init__ (owned_info )
377- self .track_publications : dict [str , RemoteTrackPublication ] = {} # type: ignore
385+ self ._track_publications : dict [str , RemoteTrackPublication ] = {} # type: ignore
386+
387+ @property
388+ def track_publications (self ) -> Mapping [str , RemoteTrackPublication ]:
389+ """
390+ A dictionary of track publications associated with the participant.
391+ """
392+ return self ._track_publications
378393
379394 def __repr__ (self ) -> str :
380395 return f"rtc.RemoteParticipant(sid={ self .sid } , identity={ self .identity } , name={ self .name } )"
0 commit comments