4040from .log import logger
4141import asyncio
4242
43- from .rpc import RpcHandlerParams
43+ from .rpc import RpcInvocationData
44+
4445
4546class PublishTrackError (Exception ):
4647 def __init__ (self , message : str ) -> None :
@@ -119,7 +120,7 @@ def __init__(
119120 self ._room_queue = room_queue
120121 self ._track_publications : dict [str , LocalTrackPublication ] = {} # type: ignore
121122 self ._rpc_handlers : Dict [
122- str , Callable [[RpcHandlerParams ], Union [Awaitable [str ], str ]]
123+ str , Callable [[RpcInvocationData ], Union [Awaitable [str ], str ]]
123124 ] = {}
124125
125126 @property
@@ -292,7 +293,7 @@ async def perform_rpc(
292293 def register_rpc_method (
293294 self ,
294295 method : str ,
295- handler : Callable [[RpcHandlerParams ], Union [Awaitable [str ], str ]],
296+ handler : Callable [[RpcInvocationData ], Union [Awaitable [str ], str ]],
296297 ) -> None :
297298 """
298299 Establishes the participant as a receiver for calls of the specified RPC method.
@@ -309,14 +310,14 @@ def register_rpc_method(
309310 RpcError: On failure. Details in `message`.
310311
311312 Example:
312- async def greet_handler(params: RpcHandlerParams ) -> str:
313- print(f"Received greeting from {params .caller_identity}: {params .payload}")
314- return f"Hello, {params .caller_identity}!"
313+ async def greet_handler(data: RpcInvocationData ) -> str:
314+ print(f"Received greeting from {data .caller_identity}: {data .payload}")
315+ return f"Hello, {data .caller_identity}!"
315316
316317 await room.local_participant.register_rpc_method('greet', greet_handler)
317318
318319 The handler should return a string or a coroutine that resolves to a string.
319-
320+
320321 If unable to respond within `response_timeout`, the caller will hang up and receive an error on their side.
321322
322323 You may raise errors of type `RpcError` with a string `message` in the handler,
@@ -340,16 +341,16 @@ def rpc_method(self, method: str):
340341
341342 Example:
342343 @local_participant.rpc_method("greet")
343- async def greet_handler(params: RpcHandlerParams ) -> str:
344- print(f"Received greeting from {params .caller_identity}: {params .payload}")
344+ async def greet_handler(data: RpcInvocationData ) -> str:
345+ print(f"Received greeting from {data .caller_identity}: {data .payload}")
345346 return f"Hello, {params.caller_identity}!"
346347
347348 See Also:
348349 `register_rpc_method` for more details
349350 """
350351
351352 def decorator (
352- handler : Callable [[RpcHandlerParams ], Union [Awaitable [str ], str ]],
353+ handler : Callable [[RpcInvocationData ], Union [Awaitable [str ], str ]],
353354 ):
354355 self .register_rpc_method (method , handler )
355356 return handler
@@ -382,8 +383,10 @@ async def _handle_rpc_method_invocation(
382383 ) -> None :
383384 response_error : Optional [RpcError ] = None
384385 response_payload : Optional [str ] = None
385-
386- params = RpcHandlerParams (request_id , caller_identity , payload , response_timeout )
386+
387+ params = RpcInvocationData (
388+ request_id , caller_identity , payload , response_timeout
389+ )
387390
388391 handler = self ._rpc_handlers .get (method )
389392
@@ -392,7 +395,7 @@ async def _handle_rpc_method_invocation(
392395 else :
393396 try :
394397 if asyncio .iscoroutinefunction (handler ):
395- async_handler = handler # type: Callable[[RpcHandlerParams ], Awaitable[str]]
398+ async_handler = handler # type: Callable[[RpcInvocationData ], Awaitable[str]]
396399
397400 async def run_handler ():
398401 try :
@@ -412,7 +415,7 @@ async def run_handler():
412415 RpcError .ErrorCode .RECIPIENT_DISCONNECTED
413416 )
414417 else :
415- sync_handler = handler # type: Callable[[RpcHandlerParams ], str]
418+ sync_handler = handler # type: Callable[[RpcInvocationData ], str]
416419 response_payload = sync_handler (params )
417420 except RpcError as error :
418421 response_error = error
0 commit comments