examples: use task.cancel() when participant leaves or disconnects

This commit is contained in:
Aleix Conchillo Flaqué
2025-01-28 15:02:37 -08:00
parent ba358a4f0a
commit 3fe2124314
48 changed files with 81 additions and 123 deletions

View File

@@ -79,11 +79,13 @@ async def main(room_url: str, token: str):
@transport.event_handler("on_participant_left")
async def on_participant_left(transport, participant, reason):
await task.queue_frame(EndFrame())
await task.cancel()
@transport.event_handler("on_call_state_updated")
async def on_call_state_updated(transport, state):
if state == "left":
# Here we don't want to cancel, we just want to finish sending
# whatever is queued, so we use an EndFrame().
await task.queue_frame(EndFrame())
runner = PipelineRunner()