|
13 | 13 | # limitations under the License. |
14 | 14 | from __future__ import annotations |
15 | 15 |
|
| 16 | +import datetime |
16 | 17 | import asyncio |
17 | 18 | import ctypes |
18 | 19 | import logging |
|
70 | 71 | "disconnected", |
71 | 72 | "reconnecting", |
72 | 73 | "reconnected", |
| 74 | + "room_updated", |
| 75 | + "moved", |
73 | 76 | ] |
74 | 77 |
|
75 | 78 |
|
@@ -234,6 +237,60 @@ def e2ee_manager(self) -> E2EEManager: |
234 | 237 | E2EEManager: The E2EE manager instance. |
235 | 238 | """ |
236 | 239 | return self._e2ee_manager |
| 240 | + |
| 241 | + @property |
| 242 | + def num_participants(self) -> int: |
| 243 | + """Gets the number of participants in the room. |
| 244 | + |
| 245 | + Returns: |
| 246 | + int: The number of participants in the room. |
| 247 | + """ |
| 248 | + return self._info.num_participants |
| 249 | + |
| 250 | + @property |
| 251 | + def num_publishers(self) -> int: |
| 252 | + """Gets the number of publishers in the room. |
| 253 | + |
| 254 | + Returns: |
| 255 | + int: The number of publishers in the room. |
| 256 | + """ |
| 257 | + return self._info.num_publishers |
| 258 | + |
| 259 | + @property |
| 260 | + def creation_time(self) -> datetime.datetime: |
| 261 | + """Time when the room was created. |
| 262 | + |
| 263 | + Returns: |
| 264 | + datetime.datetime: The creation time of the room. |
| 265 | + """ |
| 266 | + return datetime.datetime.fromtimestamp(self._info.creation_time / 1000, datetime.timezone.utc) |
| 267 | + |
| 268 | + @property |
| 269 | + def is_recording(self) -> bool: |
| 270 | + """Whether the room is actively recording. |
| 271 | + |
| 272 | + Returns: |
| 273 | + bool: True if actively recording, False otherwise. |
| 274 | + """ |
| 275 | + return self._info.active_recording |
| 276 | + |
| 277 | + @property |
| 278 | + def departure_timeout(self) -> float: |
| 279 | + """Amount of time to hold the room open after the last standard participant leaves. |
| 280 | + |
| 281 | + Returns: |
| 282 | + float: The departure timeout of the room. |
| 283 | + """ |
| 284 | + return float(self._info.departure_timeout) |
| 285 | + |
| 286 | + @property |
| 287 | + def empty_timeout(self) -> float: |
| 288 | + """Amount of time to keep the room open if no participants join. |
| 289 | + |
| 290 | + Returns: |
| 291 | + float: The empty timeout of the room. |
| 292 | + """ |
| 293 | + return float(self._info.empty_timeout) |
237 | 294 |
|
238 | 295 | def isconnected(self) -> bool: |
239 | 296 | """Checks if the room is currently connected. |
@@ -311,6 +368,10 @@ def on(self, event: EventTypes, callback: Optional[Callable] = None) -> Callable |
311 | 368 | - Arguments: None |
312 | 369 | - **"reconnected"**: Called when the room has successfully reconnected. |
313 | 370 | - Arguments: None |
| 371 | + - **"room_updated"**: Called when any information about the room is updated. |
| 372 | + - Arguments: None |
| 373 | + - **"moved"**: Called when the participant has been moved to another room. |
| 374 | + - Arguments: None |
314 | 375 |
|
315 | 376 | Example: |
316 | 377 | ```python |
@@ -771,7 +832,18 @@ def _on_room_event(self, event: proto_room.RoomEvent): |
771 | 832 | task.add_done_callback(self._data_stream_tasks.discard) |
772 | 833 |
|
773 | 834 | elif which == "room_updated": |
774 | | - print(f"received room update: {event.room_updated}") |
| 835 | + self._info = event.room_updated |
| 836 | + self.emit("room_updated") |
| 837 | + |
| 838 | + elif which == "moved": |
| 839 | + self._info = event.moved |
| 840 | + self.emit("moved") |
| 841 | + |
| 842 | + elif which == "participants_updated": |
| 843 | + for info in event.participants_updated.participants: |
| 844 | + participant = self._retrieve_participant(info.identity) |
| 845 | + if participant: |
| 846 | + participant._info = info |
775 | 847 |
|
776 | 848 | def _handle_stream_header( |
777 | 849 | self, header: proto_room.DataStream.Header, participant_identity: str |
|
0 commit comments