where should i call a method to run after the call...
# ask-ai
t
where should i call a method to run after the call end or room disconnected
t
Thanks for reaching out, Youssef. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd be happy to help you run a method after a call ends or a room gets disconnected in LiveKit! Here are some friendly pointers to guide you: • For Server-Side Agents: You can use
ctx.add_shutdown_hook()
to register a shutdown hook, which is perfect for cleanup tasks. Another great option is to listen for the
disconnected
event on
context.room
and take care of cleanup right within that event listener. • For Client-Side Applications: Simply attach a listener to the
disconnected
event of the
Room
object. For instance, in JavaScript, you might use
room.once('disconnected', (room, error) => { ... })
to handle it smoothly. If you'd like, I can share some specific examples or help you further with this—just let me know! Sources: sip-refer/agent.py | quickstart/src/joinroom.js | callkit/callkit-example/CallManager.swift | Docs::Agents