Update: 2026-07-22 17:58:19

This commit is contained in:
Hamza-Ayed
2026-07-22 17:58:19 +03:00
parent 939c7a9c2c
commit 771b436c69
2 changed files with 135 additions and 4 deletions
@@ -266,6 +266,12 @@ class LocationController extends GetxController with WidgetsBindingObserver {
if (sid != null || eid != null) {
isSocketConnected = true;
if (myLocation.latitude != 0) {
print("🚀 Sending initial location to socket after connect...");
emitLocationToSocket(myLocation, heading, speed);
}
_startHeartbeat();
// 🆕 طلب أي رحلات انتظار فاتتنا أثناء انقطاع الاتصال
@@ -444,10 +450,6 @@ class LocationController extends GetxController with WidgetsBindingObserver {
void _startHeartbeat() {
_socketHeartbeat?.cancel();
_socketHeartbeat = Timer.periodic(const Duration(seconds: 25), (timer) {
// [Fix 6] تخطي الإرسال إذا كان stream الموقع نشطاً.
// الـ _locSub يرسل update_location عند كل تحرك (كل 5-10 ثوانٍ) تلقائياً.
// الـ heartbeat يكون مفيداً فقط عندما يتوقف الـ stream (الجهاز ثابت أو أوقف الخدمة).
if (_locSub != null) return;
if (socket == null || !isSocketConnected || myLocation.latitude == 0) return;
if (isBusMode) {