Update: 2026-07-22 17:49:27

This commit is contained in:
Hamza-Ayed
2026-07-22 17:49:28 +03:00
parent ccbe3ab88d
commit 939c7a9c2c
4 changed files with 20 additions and 18 deletions
@@ -97,7 +97,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
@override
Future<void> onInit() async {
super.onInit();
Log.print('🚀 LocationController Starting...');
print('🚀 LocationController Starting...');
// 1. Register Lifecycle Observer
WidgetsBinding.instance.addObserver(this);
@@ -106,7 +106,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
// مراقب الحالة (Status Watcher)
box.listenKey(BoxName.statusDriverLocation, (value) {
if (value == 'blocked') {
Log.print("⛔ Driver is Blocked: Force Stopping Location Updates.");
print("⛔ Driver is Blocked: Force Stopping Location Updates.");
stopLocationUpdates();
if (socket != null && socket!.connected) {
socket!.emit('update_location', {
@@ -136,7 +136,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
await startLocationUpdates();
}
Log.print('✅ LocationController Initialized.');
print('✅ LocationController Initialized.');
}
@override
@@ -219,14 +219,13 @@ class LocationController extends GetxController with WidgetsBindingObserver {
// تنظيف السوكيت القديم فقط إذا كان موجوداً وغير متصل
if (socket != null) {
Log.print("🧹 Cleaning up old socket instance...");
print("🧹 Cleaning up old socket instance...");
socket!.clearListeners();
socket!.dispose();
socket = null;
}
Log.print(
"🟡 [LocationController] Initializing NEW Socket for Driver: $driverId");
print("🟡 [LocationController] Initializing NEW Socket for Driver: $driverId");
try {
// العودة للـ Websocket حصراً لأنه الوحيد الذي ينجح في فتح القناة
@@ -242,7 +241,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
socket!.connect();
} catch (e) {
_isInitializingSocket = false;
Log.print("❌ Socket Initialization Exception: $e");
print("❌ Socket Initialization Exception: $e");
}
}
@@ -262,7 +261,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
String? sid = socket?.id;
String? eid = socket?.io.engine?.id;
Log.print(
print(
'✅ Socket Connected! ID: ${sid ?? eid ?? 'N/A'} (SID: $sid, EID: $eid)');
if (sid != null || eid != null) {
@@ -270,7 +269,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
_startHeartbeat();
// 🆕 طلب أي رحلات انتظار فاتتنا أثناء انقطاع الاتصال
Log.print("📦 Requesting pending orders after reconnect...");
print("📦 Requesting pending orders after reconnect...");
socket!.emit('get_pending_orders');
}
});
@@ -278,19 +277,19 @@ class LocationController extends GetxController with WidgetsBindingObserver {
socket!.onDisconnect((data) {
_isInitializingSocket = false;
Log.print('❌ Socket Disconnected: $data');
print('❌ Socket Disconnected: $data');
isSocketConnected = false;
_stopHeartbeat();
});
socket!.onConnectError((err) {
_isInitializingSocket = false;
Log.print('❌ Socket Connect Error: $err');
print('❌ Socket Connect Error: $err');
});
socket!.onConnectTimeout((data) {
_isInitializingSocket = false;
Log.print('❌ Socket Connect Timeout: $data');
print('❌ Socket Connect Timeout: $data');
});
socket!.onError((err) {