onDisconnected method
Implementation
void onDisconnected(BuildContext context) {
if (!_isConnected) return;
_isConnected = false;
_disconnectedRunIds.addAll(_eventQueues.keys);
final error = CometChatException(
'Disconnected',
'Disconnected. The connection was lost while streaming events.',
cc.Translations.of(context).somethingWentWrongTryAgain,
);
for (final runId in _disconnectedRunIds.toList()) {
final controller = _controllers[runId];
if (controller != null && !controller.isClosed) {
_onErrorCallbacks[runId]?.call(error);
controller.addError(error);
controller.close();
}
_controllers.remove(runId);
_onErrorCallbacks.remove(runId);
}
_stopAllActiveRuns();
debugPrint('[AI Stream] Disconnected');
CometChatStreamCallBackEvents.ccStreamInterrupted(true);
}