Skip to content

Commit b518e68

Browse files
committed
kwargs
1 parent a524032 commit b518e68

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ The caller may then initiate an RPC call like so:
155155
```python
156156
try:
157157
response = await room.local_participant.perform_rpc(
158-
'recipient-identity',
159-
'greet',
160-
'Hello from RPC!'
158+
destination_identity='recipient-identity',
159+
method='greet',
160+
payload='Hello from RPC!'
161161
)
162162
print(f"RPC response: {response}")
163163
except Exception as e:

examples/rpc.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ async def perform_greeting(room: rtc.Room):
152152
print("[Caller] Letting the greeter know that I've arrived")
153153
try:
154154
response = await room.local_participant.perform_rpc(
155-
"greeter", "arrival", "Hello"
155+
destination_identity="greeter",
156+
method="arrival",
157+
payload="Hello"
156158
)
157159
print(f'[Caller] That\'s nice, the greeter said: "{response}"')
158160
except Exception as error:
@@ -164,7 +166,9 @@ async def perform_square_root(room: rtc.Room):
164166
print("[Caller] What's the square root of 16?")
165167
try:
166168
response = await room.local_participant.perform_rpc(
167-
"math-genius", "square-root", json.dumps({"number": 16})
169+
destination_identity="math-genius",
170+
method="square-root",
171+
payload=json.dumps({"number": 16})
168172
)
169173
parsed_response = json.loads(response)
170174
print(f"[Caller] Nice, the answer was {parsed_response['result']}")
@@ -177,7 +181,9 @@ async def perform_quantum_hypergeometric_series(room: rtc.Room):
177181
print("[Caller] What's the quantum hypergeometric series of 42?")
178182
try:
179183
response = await room.local_participant.perform_rpc(
180-
"math-genius", "quantum-hypergeometric-series", json.dumps({"number": 42})
184+
destination_identity="math-genius",
185+
method="quantum-hypergeometric-series",
186+
payload=json.dumps({"number": 42})
181187
)
182188
parsed_response = json.loads(response)
183189
print(f"[Caller] genius says {parsed_response['result']}!")
@@ -196,7 +202,9 @@ async def perform_divide(room: rtc.Room):
196202
print("[Caller] Let's divide 10 by 0.")
197203
try:
198204
response = await room.local_participant.perform_rpc(
199-
"math-genius", "divide", json.dumps({"dividend": 10, "divisor": 0})
205+
destination_identity="math-genius",
206+
method="divide",
207+
payload=json.dumps({"dividend": 10, "divisor": 0})
200208
)
201209
parsed_response = json.loads(response)
202210
print(f"[Caller] The result is {parsed_response['result']}")
@@ -215,9 +223,9 @@ async def perform_long_calculation(room: rtc.Room):
215223
print("[Caller] Giving the math genius 10s to complete a long calculation")
216224
try:
217225
response = await room.local_participant.perform_rpc(
218-
"math-genius",
219-
"long-calculation",
220-
json.dumps({}),
226+
destination_identity="math-genius",
227+
method="long-calculation",
228+
payload=json.dumps({}),
221229
response_timeout=10
222230
)
223231
parsed_response = json.loads(response)

livekit-rtc/livekit/rtc/participant.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class PublishTranscriptionError(Exception):
6565
def __init__(self, message: str) -> None:
6666
self.message = message
6767

68-
6968
class Participant(ABC):
7069
def __init__(self, owned_info: proto_participant.OwnedParticipant) -> None:
7170
self._info = owned_info.info
@@ -245,6 +244,7 @@ async def publish_transcription(self, transcription: Transcription) -> None:
245244

246245
async def perform_rpc(
247246
self,
247+
*,
248248
destination_identity: str,
249249
method: str,
250250
payload: str,
@@ -603,3 +603,5 @@ def __repr__(self) -> str:
603603
return f"rtc.RemoteParticipant(sid={self.sid}, identity={self.identity}, name={self.name})"
604604

605605

606+
607+

0 commit comments

Comments
 (0)