Update the correct MQTT client with latest changes #783

This commit is contained in:
Ramon Gutierrez 2024-03-07 23:41:21 +08:00
parent a4b883b7ea
commit d603934d93
2 changed files with 28 additions and 1 deletions

View file

@ -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));
}
}

View file

@ -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));
}
}