disconnectSocket method
void
disconnectSocket()
Disconnects socket safely
Implementation
void disconnectSocket() {
if (_socket != null) {
if (_receiverId.isNotEmpty) {
// Just update status for specific chat
_log('Leaving chat room with $_receiverId');
updateUserStatus(false);
} else {
// Fully disconnect only when no active chat
_log('Fully disconnecting socket');
_socket!.disconnect();
_socket = null;
}
}
_isLoading = false;
_triggerEvent(ChatEventType.connectionStatusChanged, false);
}