clearSession method

  1. @override
Future<void> clearSession()
override

Clears the local session: deletes the stored guest ID and disconnects if currently connected. The next connect call will create a new anonymous identity and open a fresh conversation on the backend.

Use this when the customer explicitly wants to start a new support thread, or when a merchant-defined session expiry has elapsed.

Implementation

@override
Future<void> clearSession() async {
  recorded.clearSessionCalls += 1;
  _messageHistory.clear();
  if (currentConnectionState is! Disconnected) {
    await disconnect();
  }
}