RELAYCall

wait_for_ended

View as MarkdownOpen in Claude

Wait for the call to reach the ended state. This is a convenience method equivalent to waiting for a calling.call.state event with call_state == "ended".

Parameters

timeout
Optional[float]

Maximum seconds to wait. Raises asyncio.TimeoutError if exceeded. None waits indefinitely.

Returns

RelayEvent — The state-change event indicating the call has ended.

Example

1from signalwire.relay import RelayClient
2
3client = RelayClient(
4 project="your-project-id",
5 token="your-api-token",
6 host="your-space.signalwire.com",
7 contexts=["default"],
8)
9
10@client.on_call
11async def handle_call(call):
12 await call.answer()
13
14 action = await call.play([{"type": "tts", "text": "Goodbye!"}])
15 await action.wait()
16 await call.hangup()
17
18 event = await call.wait_for_ended()
19 print(f"Call {call.call_id} has ended: {event.params}")
20
21client.run()