From 309605da24af1b0bb874957e2e5cd8ab1dc2beb4 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 26 Aug 2020 04:06:50 +0000 Subject: [PATCH] Move adding/removal of rider to and from rider cache when going online/offline. #478 --- src/Service/RiderAPIHandler/CMBRiderAPIHandler.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php index 6441bf41..5f33261b 100644 --- a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php @@ -215,7 +215,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $rider_id = $rider->getID(); // cache rider location (default to hub) // TODO: figure out longitude / latitude default - $this->rcache->addActiveRider($rider_id, 0, 0); + // $this->rcache->addActiveRider($rider_id, 0, 0); // TODO: log rider logging in @@ -285,7 +285,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $rider->setActive(false); // remove from cache - $this->rcache->removeActiveRider($rider->getID()); + // $this->rcache->removeActiveRider($rider->getID()); // remove rider from session $this->session->setRider(null); @@ -318,6 +318,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $this->em->flush(); + // cache rider location (default to hub) + // TODO: figure out longitude / latitude default + $this->rcache->addActiveRider($rider_id, 0, 0); + // send mqtt event to put rider on map // get rider coordinates from redis $coord = $this->rider_tracker->getRiderLocation($rider->getID()); @@ -367,6 +371,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface $this->em->flush(); + // remove from cache + $this->rcache->removeActiveRider($rider->getID()); + // send mqtt event to remove rider from map $channel = 'rider/' . $rider->getID() . '/availability'; $payload = [