endSession static method
- @Deprecated('Use CallSession.getInstance()?.leaveSession() instead')
- required dynamic onSuccess(),
- required dynamic onError(),
Ends the current call session using the v4 API signature.
@deprecated Use CallSession.getInstance()?.leaveSession() instead.
If an active session exists, calls CallSession.leaveSession() and
invokes onSuccess with a success message. If no active session exists,
calls onError with a CometChatCallsException indicating no active session.
If leaveSession() throws, the exception is caught and forwarded to onError.
Requirements: 4.1, 4.2, 4.3
Implementation
@Deprecated('Use CallSession.getInstance()?.leaveSession() instead')
static void endSession({
required Function(String) onSuccess,
required Function(CometChatCallsException) onError,
}) async {
try {
final session = CallSession.getInstance();
if (session == null) {
// No session at all — still report success so the UI can clean up
onSuccess('Session ended successfully');
return;
}
await session.leaveSession();
onSuccess('Session ended successfully');
} on CometChatCallsException catch (e) {
onError(e);
} catch (e) {
onError(CometChatCallsException.wrapUnhandled(e));
}
}