Delete Session
Ends the current session, closes the WebSocket connection, and stops receiving events. After deletion, a new session must be created with createSession to resume SDK functionality.
Signature
// Callback version
fun deleteSession(callback: (Exception?) -> Unit)
// Suspend version
suspend fun deleteSession()Parameters
None.
Return Type
Returns void (or Promise<void> for Web). Completion indicates the session has been terminated.
Usage Example
// Callback
client.deleteSession { err ->
when {
err != null -> { } // handle error
}
}
// Coroutine
try {
client.deleteSession()
}
catch (e:Error) {
// Handle Error in creation session
}
Errors
This method can throw the following error types:
SESSION_ERROR— no active session to deleteUNKNOWN_ERROR— any unmapped exception
Notes
- Deleting a session does not end active calls — use
hangupto terminate calls before deleting the session if needed. - After deletion, all event listeners remain registered but will not fire until a new session is created.
Related Actions
createSession- Create a new session