Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherry committed Oct 8, 2024
1 parent 8923184 commit e22b112
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 38 deletions.
56 changes: 28 additions & 28 deletions livekit-rtc/livekit/rtc/_proto/rpc_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions livekit-rtc/livekit/rtc/_proto/rpc_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions livekit-rtc/livekit/rtc/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ async def _handle_rpc_method_invocation(
handler = self._rpc_handlers.get(method)

if not handler:
response_error = RpcError.built_in("UNSUPPORTED_METHOD")
response_error = RpcError._built_in(RpcError.ErrorCode.UNSUPPORTED_METHOD)
else:
try:
response_payload = await handler(
Expand All @@ -379,7 +379,7 @@ async def _handle_rpc_method_invocation(
f"Uncaught error returned by RPC handler for {method}. Returning UNCAUGHT_ERROR instead.",
error,
)
response_error = RpcError.built_in("APPLICATION_ERROR")
response_error = RpcError._built_in(RpcError.ErrorCode.APPLICATION_ERROR)

req = proto_ffi.FfiRequest(
rpc_method_invocation_response=RpcMethodInvocationResponseRequest(
Expand Down
13 changes: 11 additions & 2 deletions livekit-rtc/livekit/rtc/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ._proto import room_pb2 as proto_room
from ._proto.room_pb2 import ConnectionState
from ._proto.track_pb2 import TrackKind
from ._proto.rpc_pb2 import RpcMethodInvocationEvent
from ._utils import BroadcastQueue
from .e2ee import E2EEManager, E2EEOptions
from .participant import LocalParticipant, Participant, RemoteParticipant
Expand Down Expand Up @@ -438,12 +439,20 @@ async def _listen_task(self) -> None:
self._room_queue.put_nowait(event)
await self._room_queue.join()

def _on_rpc_method_invocation(self, rpc_invocation: proto_ffi.RpcMethodInvocation):
def _on_rpc_method_invocation(self, rpc_invocation: RpcMethodInvocationEvent):
if self._local_participant is None:
logging.warning("Received RPC invocation before local participant was initialized")
return

if (
rpc_invocation.local_participant_handle
== self._local_participant._ffi_handle.handle
): # type: ignore
):
caller = self._remote_participants.get(rpc_invocation.caller_identity)
if caller is None:
logging.warning(f"Caller {rpc_invocation.caller_identity} not found")
return

asyncio.create_task(
self._local_participant._handle_rpc_method_invocation(
rpc_invocation.invocation_id,
Expand Down
4 changes: 1 addition & 3 deletions livekit-rtc/livekit/rtc/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ def to_proto(self) -> proto_rpc.RpcError:
return proto_rpc.RpcError(code=self.code, message=self.message, data=self.data)

@classmethod
def built_in(
def _built_in(
cls, code: "RpcError.ErrorCode", data: Optional[str] = None
) -> "RpcError":
"""
Creates an error object from the ErrorCode, with an auto-populated message.
@internal
"""
message = cls.ErrorMessage[code]
return cls(code, message, data)

0 comments on commit e22b112

Please sign in to comment.