How can we make sure that a client is immediately ...
# ask-ai
i
How can we make sure that a client is immediately disconnected from a room if the user closes the client app or closes the browser window?
t
Thanks for reaching out, Tracy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
It sounds like you want participants to leave a room immediately when the app or browser closes. • From the client: call
room.disconnect()
during shutdown (e.g., app close, page unload). If this isn’t called, the server removes the participant after ~15s. Some platforms auto-disconnect on exit, but it’s best to call it explicitly for reliability. Docs • From the server (if the client can’t run cleanup): use the RemoveParticipant API to forcibly disconnect a participant. To prevent immediate rejoin, combine with short token TTLs. Docs • To end the session for everyone: use DeleteRoom to disconnect all participants and close the room. Docs Would you like brief examples for browser unload handlers or mobile app lifecycle hooks? Sources: Connecting to LiveKit | LiveKit docs | Managing participants | LiveKit docs | Managing rooms | LiveKit docs
i
Yes, please.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
i
You asked me "Would you like brief examples for browser unload handlers or mobile app lifecycle hooks?". My answer is yes, please do.