Update: 2026-07-22 17:49:27
This commit is contained in:
@@ -32,7 +32,7 @@ try {
|
|||||||
// 2. طلب بيانات السائقين من سيرفر اللوكيشن (Redis API)
|
// 2. طلب بيانات السائقين من سيرفر اللوكيشن (Redis API)
|
||||||
// — يرجع cache hits لو موجودة، وإلا يرجع IDs فقط
|
// — يرجع 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';
|
$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')) : ''));
|
$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) {
|
if ($httpCode == 200 && $response) {
|
||||||
$json = json_decode($response, true);
|
$json = json_decode($response, true);
|
||||||
if (isset($json['status']) && $json['status'] === 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');
|
$serverNow = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
foreach ($redisDrivers as $d) {
|
foreach ($redisDrivers as $d) {
|
||||||
|
$driverId = $d['driver_id'] ?? $d['id'] ?? null;
|
||||||
|
if (!$driverId) continue;
|
||||||
|
|
||||||
if (!empty($d['cached']) && !empty($d['first_name'])) {
|
if (!empty($d['cached']) && !empty($d['first_name'])) {
|
||||||
// ✅ Cache hit — بيانات السائق كاملة من Redis, نستخدمها مباشرة
|
// ✅ Cache hit — بيانات السائق كاملة من Redis, نستخدمها مباشرة
|
||||||
$d['serverNow'] = $serverNow;
|
$d['serverNow'] = $serverNow;
|
||||||
$final_result[] = $d;
|
$final_result[] = $d;
|
||||||
} else {
|
} else {
|
||||||
// ❌ Cache miss — نحتاج نجيب البيانات من MySQL
|
// ❌ Cache miss — نحتاج نجيب البيانات من MySQL
|
||||||
$mysqlIds[] = $d['id'];
|
$mysqlIds[] = $driverId;
|
||||||
$driversMap[$d['id']] = $d;
|
$driversMap[$driverId] = $d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class AppLink {
|
|||||||
case 'Egypt':
|
case 'Egypt':
|
||||||
return 'https://location-egypt.siromove.com/siro/ride/location';
|
return 'https://location-egypt.siromove.com/siro/ride/location';
|
||||||
case 'Jordan':
|
case 'Jordan':
|
||||||
return 'https://location.intaleq.xyz/intaleq/ride/location';
|
return 'https://jordan-siro.intaleqapp.com/backend/ride/location';
|
||||||
default:
|
default:
|
||||||
return 'https://location-jordan.siromove.com/siro/ride/location';
|
return 'https://location-jordan.siromove.com/siro/ride/location';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
@override
|
@override
|
||||||
Future<void> onInit() async {
|
Future<void> onInit() async {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
Log.print('🚀 LocationController Starting...');
|
print('🚀 LocationController Starting...');
|
||||||
|
|
||||||
// 1. Register Lifecycle Observer
|
// 1. Register Lifecycle Observer
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
@@ -106,7 +106,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
// مراقب الحالة (Status Watcher)
|
// مراقب الحالة (Status Watcher)
|
||||||
box.listenKey(BoxName.statusDriverLocation, (value) {
|
box.listenKey(BoxName.statusDriverLocation, (value) {
|
||||||
if (value == 'blocked') {
|
if (value == 'blocked') {
|
||||||
Log.print("⛔ Driver is Blocked: Force Stopping Location Updates.");
|
print("⛔ Driver is Blocked: Force Stopping Location Updates.");
|
||||||
stopLocationUpdates();
|
stopLocationUpdates();
|
||||||
if (socket != null && socket!.connected) {
|
if (socket != null && socket!.connected) {
|
||||||
socket!.emit('update_location', {
|
socket!.emit('update_location', {
|
||||||
@@ -136,7 +136,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
await startLocationUpdates();
|
await startLocationUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.print('✅ LocationController Initialized.');
|
print('✅ LocationController Initialized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -219,14 +219,13 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
|
|
||||||
// تنظيف السوكيت القديم فقط إذا كان موجوداً وغير متصل
|
// تنظيف السوكيت القديم فقط إذا كان موجوداً وغير متصل
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
Log.print("🧹 Cleaning up old socket instance...");
|
print("🧹 Cleaning up old socket instance...");
|
||||||
socket!.clearListeners();
|
socket!.clearListeners();
|
||||||
socket!.dispose();
|
socket!.dispose();
|
||||||
socket = null;
|
socket = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.print(
|
print("🟡 [LocationController] Initializing NEW Socket for Driver: $driverId");
|
||||||
"🟡 [LocationController] Initializing NEW Socket for Driver: $driverId");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// العودة للـ Websocket حصراً لأنه الوحيد الذي ينجح في فتح القناة
|
// العودة للـ Websocket حصراً لأنه الوحيد الذي ينجح في فتح القناة
|
||||||
@@ -242,7 +241,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
socket!.connect();
|
socket!.connect();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_isInitializingSocket = false;
|
_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? sid = socket?.id;
|
||||||
String? eid = socket?.io.engine?.id;
|
String? eid = socket?.io.engine?.id;
|
||||||
|
|
||||||
Log.print(
|
print(
|
||||||
'✅ Socket Connected! ID: ${sid ?? eid ?? 'N/A'} (SID: $sid, EID: $eid)');
|
'✅ Socket Connected! ID: ${sid ?? eid ?? 'N/A'} (SID: $sid, EID: $eid)');
|
||||||
|
|
||||||
if (sid != null || eid != null) {
|
if (sid != null || eid != null) {
|
||||||
@@ -270,7 +269,7 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
_startHeartbeat();
|
_startHeartbeat();
|
||||||
|
|
||||||
// 🆕 طلب أي رحلات انتظار فاتتنا أثناء انقطاع الاتصال
|
// 🆕 طلب أي رحلات انتظار فاتتنا أثناء انقطاع الاتصال
|
||||||
Log.print("📦 Requesting pending orders after reconnect...");
|
print("📦 Requesting pending orders after reconnect...");
|
||||||
socket!.emit('get_pending_orders');
|
socket!.emit('get_pending_orders');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -278,19 +277,19 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
|||||||
|
|
||||||
socket!.onDisconnect((data) {
|
socket!.onDisconnect((data) {
|
||||||
_isInitializingSocket = false;
|
_isInitializingSocket = false;
|
||||||
Log.print('❌ Socket Disconnected: $data');
|
print('❌ Socket Disconnected: $data');
|
||||||
isSocketConnected = false;
|
isSocketConnected = false;
|
||||||
_stopHeartbeat();
|
_stopHeartbeat();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket!.onConnectError((err) {
|
socket!.onConnectError((err) {
|
||||||
_isInitializingSocket = false;
|
_isInitializingSocket = false;
|
||||||
Log.print('❌ Socket Connect Error: $err');
|
print('❌ Socket Connect Error: $err');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket!.onConnectTimeout((data) {
|
socket!.onConnectTimeout((data) {
|
||||||
_isInitializingSocket = false;
|
_isInitializingSocket = false;
|
||||||
Log.print('❌ Socket Connect Timeout: $data');
|
print('❌ Socket Connect Timeout: $data');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket!.onError((err) {
|
socket!.onError((err) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class AppLink {
|
|||||||
case 'Egypt':
|
case 'Egypt':
|
||||||
return 'https://location-egypt.siromove.com/siro/ride/location';
|
return 'https://location-egypt.siromove.com/siro/ride/location';
|
||||||
case 'Jordan':
|
case 'Jordan':
|
||||||
return 'https://location.intaleq.xyz/intaleq/ride/location';
|
return 'https://jordan-siro.intaleqapp.com/backend/ride/location';
|
||||||
default:
|
default:
|
||||||
return 'https://location.siromove.com/siro/ride/location';
|
return 'https://location.siromove.com/siro/ride/location';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user