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
float | NoneDefaults to None

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

Returns

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

Example

from signalwire.relay import RelayClient
client = RelayClient(
project="your-project-id",
token="your-api-token",
contexts=["default"],
)
@client.on_call
async def handle_call(call):
await call.answer()
action = await call.play([{"type": "tts", "params": {"text": "Goodbye!"}}])
await action.wait()
await call.hangup()
event = await call.wait_for_ended()
print(f"Call {call.call_id} has ended: {event.params}")
client.run()