Skip to content
Prev Previous commit
Next Next commit
type check
  • Loading branch information
typester committed Mar 13, 2025
commit 0a6be2dd119a7bbc0bf564cf3971e895db362c57
1 change: 1 addition & 0 deletions livekit-rtc/livekit/rtc/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ async def greet_handler(data: RpcInvocationData) -> str:
room = self.room
if room is not None:
return room.register_rpc_method(method_name, handler)
return None

def unregister_rpc_method(self, method: str) -> None:
"""
Expand Down
5 changes: 5 additions & 0 deletions livekit-rtc/livekit/rtc/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ async def greet_handler(data: RpcInvocationData) -> str:
"""

def register(handler_func):
if self._ffi_handle is None:
raise Exception("cannot register RPC method before room is connected")
self._rpc_handlers[method_name] = handler_func
req = proto_ffi.FfiRequest()
req.register_rpc_method.room_handle = self._ffi_handle.handle
Expand All @@ -517,6 +519,9 @@ def unregister_rpc_method(self, method: str) -> None:
Args:
method (str): The name of the RPC method to unregister
"""
if self._ffi_handle is None:
raise Exception("cannot unregister RPC method before room is connected")

self._rpc_handlers.pop(method, None)

req = proto_ffi.FfiRequest()
Expand Down
Loading