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
+7 -4
View File
@@ -32,7 +32,7 @@ try {
// 2. طلب بيانات السائقين من سيرفر اللوكيشن (Redis API)
// — يرجع cache hits لو موجودة، وإلا يرجع IDs فقط
// ==========================================
$locationServerUrl = getenv('LOCATION_API_URL') ?: 'http://nginx/loction_server/api_get_nearby.php';
$locationServerUrl = getenv('LOCATION_API_URL') ?: 'https://jordan-siro.intaleqapp.com/loction_server/api_get_nearby.php';
$keyPath = getenv('INTERNAL_SOCKET_KEY_PATH') ?: '/keys/.internal_socket_key';
$INTERNAL_KEY = getenv('INTERNAL_SOCKET_KEY') ?: (file_exists($keyPath) ? trim((string)@file_get_contents($keyPath)) : (file_exists('/home/location/.internal_socket_key') ? trim((string)@file_get_contents('/home/location/.internal_socket_key')) : ''));
@@ -57,7 +57,7 @@ try {
if ($httpCode == 200 && $response) {
$json = json_decode($response, true);
if (isset($json['status']) && $json['status'] === true) {
$redisDrivers = $json['data'];
$redisDrivers = $json['drivers'] ?? $json['data'] ?? [];
}
}
@@ -73,14 +73,17 @@ try {
$serverNow = date('Y-m-d H:i:s');
foreach ($redisDrivers as $d) {
$driverId = $d['driver_id'] ?? $d['id'] ?? null;
if (!$driverId) continue;
if (!empty($d['cached']) && !empty($d['first_name'])) {
// ✅ Cache hit — بيانات السائق كاملة من Redis, نستخدمها مباشرة
$d['serverNow'] = $serverNow;
$final_result[] = $d;
} else {
// ❌ Cache miss — نحتاج نجيب البيانات من MySQL
$mysqlIds[] = $d['id'];
$driversMap[$d['id']] = $d;
$mysqlIds[] = $driverId;
$driversMap[$driverId] = $d;
}
}
+1 -1
View File
@@ -50,7 +50,7 @@ class AppLink {
case 'Egypt':
return 'https://location-egypt.siromove.com/siro/ride/location';
case 'Jordan':
return 'https://location.intaleq.xyz/intaleq/ride/location';
return 'https://jordan-siro.intaleqapp.com/backend/ride/location';
default:
return 'https://location-jordan.siromove.com/siro/ride/location';
}
@@ -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) {
+1 -1
View File
@@ -46,7 +46,7 @@ class AppLink {
case 'Egypt':
return 'https://location-egypt.siromove.com/siro/ride/location';
case 'Jordan':
return 'https://location.intaleq.xyz/intaleq/ride/location';
return 'https://jordan-siro.intaleqapp.com/backend/ride/location';
default:
return 'https://location.siromove.com/siro/ride/location';
}