1616import datetime
1717import asyncio
1818import ctypes
19- import enum
2019import logging
2120from dataclasses import dataclass , field
2221from typing import Callable , Dict , Literal , Optional , cast , Mapping
2928from ._proto import room_pb2 as proto_room
3029from ._proto import stats_pb2 as proto_stats
3130from ._proto .participant_pb2 import DisconnectReason
32- from ._proto .room_pb2 import ConnectionState
31+ from ._proto .room_pb2 import ConnectionState , SimulateScenarioKind
3332from ._proto .track_pb2 import TrackKind
3433from ._proto .rpc_pb2 import RpcMethodInvocationEvent
3534from ._utils import BroadcastQueue
@@ -596,11 +595,11 @@ def unregister_text_stream_handler(self, topic: str):
596595 if self ._text_stream_handlers .get (topic ):
597596 self ._text_stream_handlers .pop (topic )
598597
599- async def simulate_scenario (self , scenario : "SimulateScenario" ) -> None :
598+ async def simulate_scenario (self , scenario : SimulateScenarioKind . ValueType ) -> None :
600599 """Trigger a reconnection / chaos scenario for testing.
601600
602- See `SimulateScenario ` for the available variants. Most useful in
603- tests to deterministically force a Resume (signal-only reconnect
601+ See `SimulateScenarioKind ` for the available variants. Most useful
602+ in tests to deterministically force a Resume (signal-only reconnect
604603 that preserves the PeerConnection and existing publications) or a
605604 full reconnect (the SDK rebuilds the RtcSession and re-publishes
606605 existing local tracks).
@@ -612,7 +611,7 @@ async def simulate_scenario(self, scenario: "SimulateScenario") -> None:
612611
613612 req = proto_ffi .FfiRequest ()
614613 req .simulate_scenario .room_handle = self ._ffi_handle .handle
615- req .simulate_scenario .scenario = scenario . value
614+ req .simulate_scenario .scenario = scenario
616615 queue = FfiClient .instance .queue .subscribe ()
617616 try :
618617 resp = FfiClient .instance .request (req )
@@ -1082,23 +1081,3 @@ def __repr__(self) -> str:
10821081 sid = self ._first_sid_future .result ()
10831082
10841083 return f"rtc.Room(sid={ sid } , name={ self .name } , metadata={ self .metadata } , connection_state={ ConnectionState .Name (self ._connection_state )} )"
1085-
1086-
1087- class SimulateScenario (enum .IntEnum ):
1088- """Reconnection / chaos scenarios that can be triggered via
1089- :meth:`Room.simulate_scenario`. The values match the underlying FFI
1090- ``SimulateScenarioKind`` proto enum."""
1091-
1092- # Closes the signal channel locally; engine attempts a Resume reconnect
1093- # (PeerConnection preserved, publications kept).
1094- SIGNAL_RECONNECT = proto_room .SimulateScenarioKind .SIMULATE_SIGNAL_RECONNECT
1095- SPEAKER = proto_room .SimulateScenarioKind .SIMULATE_SPEAKER
1096- NODE_FAILURE = proto_room .SimulateScenarioKind .SIMULATE_NODE_FAILURE
1097- SERVER_LEAVE = proto_room .SimulateScenarioKind .SIMULATE_SERVER_LEAVE
1098- MIGRATION = proto_room .SimulateScenarioKind .SIMULATE_MIGRATION
1099- FORCE_TCP = proto_room .SimulateScenarioKind .SIMULATE_FORCE_TCP
1100- FORCE_TLS = proto_room .SimulateScenarioKind .SIMULATE_FORCE_TLS
1101- # Asks the server to send LeaveRequest{Reconnect}, forcing a full
1102- # reconnect (new RtcSession; SDK republishes existing local tracks;
1103- # `Reconnected` event will fire).
1104- FULL_RECONNECT = proto_room .SimulateScenarioKind .SIMULATE_FULL_RECONNECT
0 commit comments