From d603934d933ee755a802770f0c53d22f2332e57b Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Thu, 7 Mar 2024 23:41:21 +0800 Subject: [PATCH] Update the correct MQTT client with latest changes #783 --- src/Service/MQTTClient.php | 2 +- src/Service/MQTTClientApiv2.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Service/MQTTClient.php b/src/Service/MQTTClient.php index f1f3f2b3..00229f5f 100644 --- a/src/Service/MQTTClient.php +++ b/src/Service/MQTTClient.php @@ -89,6 +89,6 @@ class MQTTClient */ // NOTE: this is for the new rider app - $this->publish('rider/' . $rider->getID() . '/delivery', json_encode($payload)); + $this->publish('rider/' . $rider->getID(), json_encode($payload)); } } diff --git a/src/Service/MQTTClientApiv2.php b/src/Service/MQTTClientApiv2.php index 42b85648..f819be53 100644 --- a/src/Service/MQTTClientApiv2.php +++ b/src/Service/MQTTClientApiv2.php @@ -68,4 +68,31 @@ class MQTTClientApiv2 // error_log('sent to ' . $channel); } } + + public function sendRiderEvent(JobOrder $job_order, $payload) + { + // check if a rider is available + $rider = $job_order->getRider(); + if ($rider == null) + return; + + /* + // NOTE: this is for the old rider app + // check if rider has sessions + $sessions = $rider->getSessions(); + if (count($sessions) == 0) + return; + + // send to every rider session + foreach ($sessions as $sess) + { + $sess_id = $sess->getID(); + $channel = self::RIDER_PREFIX . $sess_id; + $this->publish($channel, json_encode($payload)); + } + */ + + // NOTE: this is for the new rider app + $this->publish('rider/' . $rider->getID() . '/delivery', json_encode($payload)); + } }