onChatStateChanged

open fun onChatStateChanged(stateEvent: StateEvent)

Notifies the listener that the chat session's lifecycle state has changed.

This method is called whenever the chat transitions between states (for example, from StateEvent.Preparing to StateEvent.Started, or StateEvent.Ending to StateEvent.Ended). Use StateEvent.state to drive UI updates and StateEvent.data for any associated payload.

Usage:

override fun onChatStateChanged(stateEvent: StateEvent) {
when (stateEvent.state) {
StateEvent.Started -> {
// Update UI to reflect active chat.
}
StateEvent.Closed -> {
val reason = stateEvent.data as? EndedReason
// Handle the end reason.
}
StateEvent.Disconnected -> {
// Show reconnect option.
}
}
}

Parameters

stateEvent

The StateEvent describing the new state and any associated data.