Event Handling
A Call produces discrete events (for example hangup and errors) and
continuous audio streams. Register connector-level handlers before
run_forever(), and attach call-level handlers after process_call.
Connector-level notifications
Register on SessionManager before run_forever():
Each inbound call handler typically runs in its own task (concurrent calls). Notifications that arrive between connect and run_forever() are buffered, not dropped.
Call events
on_hangup is shorthand for on_call_event(CallEvent.HANGUP). Handlers take exactly one argument. Sync handlers run on a worker thread so they do not stall audio delivery.
CallEvent in 1.0.0: HANGUP, ERROR.
You can also register without a decorator:
Audio streams
Once the call terminates, send_audio / clear_send_audio_buffer raise CallClosedError. A hangup can land mid-response - catch it as the stop signal and cancel model tasks in your hangup handler.
Ordering and concurrency
- Notifications are connector-wide competing-consumer: concurrent and possibly out of order. Correlate by
(subscriber, participant)orcall_id. - Dedup redelivered notifications (at-least-once).
- Do not assume audio chunks and hangup events are ordered relative to your model’s network I/O - always clear the buffer on interrupt and cancel tasks on hangup.
