Skip to content

Commit 0f9e026

Browse files
committed
avoid redefining SimulateScenario
1 parent 57d4030 commit 0f9e026

3 files changed

Lines changed: 8 additions & 29 deletions

File tree

livekit-rtc/livekit/rtc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
DataPacketKind,
3434
IceServer,
3535
IceTransportType,
36+
SimulateScenarioKind,
3637
TrackPublishOptions,
3738
VideoEncoding,
3839
)
@@ -65,7 +66,6 @@
6566
Room,
6667
RoomOptions,
6768
RtcConfiguration,
68-
SimulateScenario,
6969
SipDTMF,
7070
RtcStats,
7171
)
@@ -160,7 +160,7 @@
160160
"Room",
161161
"RoomOptions",
162162
"RtcConfiguration",
163-
"SimulateScenario",
163+
"SimulateScenarioKind",
164164
"SipDTMF",
165165
"RtcStats",
166166
"DataPacket",

livekit-rtc/livekit/rtc/data_track.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async def __anext__(self) -> DataTrackFrame:
248248
elif detail == "eos":
249249
self._close()
250250
if stream_event.eos.HasField("error"):
251-
raise SubscribeDataTrackError(stream_event.eos.error)
251+
raise SubscribeDataTrackError(stream_event.eos.error.message)
252252
raise StopAsyncIteration
253253
else:
254254
self._close()

livekit-rtc/livekit/rtc/room.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import datetime
1717
import asyncio
1818
import ctypes
19-
import enum
2019
import logging
2120
from dataclasses import dataclass, field
2221
from typing import Callable, Dict, Literal, Optional, cast, Mapping
@@ -29,7 +28,7 @@
2928
from ._proto import room_pb2 as proto_room
3029
from ._proto import stats_pb2 as proto_stats
3130
from ._proto.participant_pb2 import DisconnectReason
32-
from ._proto.room_pb2 import ConnectionState
31+
from ._proto.room_pb2 import ConnectionState, SimulateScenarioKind
3332
from ._proto.track_pb2 import TrackKind
3433
from ._proto.rpc_pb2 import RpcMethodInvocationEvent
3534
from ._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

Comments
 (0)