kind-school-76204
07/25/2025, 1:46 AMtall-airline-16756
07/25/2025, 1:46 AMtall-airline-16756
07/25/2025, 1:47 AMCloseEvent is emitted when an agent session is closed. This can happen for reasons such as the user ending the conversation, calling session.aclose(), room deletion, or an unrecoverable error. The event includes an error property with details if an error caused the closure.
Example of handling the close event in an agent session:
@session.on("close")
def on_close(ev: CloseEvent):
print(f"Agent Session closed, reason: {ev.reason}")
Regular Client Sessions:
• Participants receive a Disconnected event when disconnected from a room. This can occur due to server actions like room deletion, participant removal, or other reasons such as DUPLICATE_IDENTITY or ROOM_DELETED.
SDK-Level Implementation:
• Rust SDK: Uses a Close event in the SessionEvent enum, including details like source, reason, and retry information.
• Android SDK: Implements an onClose callback method with the reason and code for the closure.
• JavaScript SDK: Handles close events through the SignalClient with appropriate callback mechanisms.
The specific event names and handling mechanisms vary between SDKs, but all provide ways for clients to be notified when sessions are closed.
Sources: Events and error handling | LiveKit Docs | livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/stt.py | Connecting to LiveKit | LiveKit Docs | livekit/src/rtc_engine/rtc_session.rs | livekit-android-test/src/test/java/io/livekit/android/room/SignalClientTest...