mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-21 08:56:27 +02:00
Use id_phone instead of number in scheduled, use ftok to generate queue id, improve adapter interface, add popup error
This commit is contained in:
parent
66fa2ef434
commit
6f8c7d62b9
25 changed files with 195 additions and 180 deletions
|
@ -101,7 +101,7 @@ class Launcher extends AbstractDaemon
|
|||
{
|
||||
foreach ($phones as $phone)
|
||||
{
|
||||
$phone_name = 'RaspiSMS Daemon Phone ' . $phone['number'];
|
||||
$phone_name = 'RaspiSMS Daemon Phone ' . $phone['id'];
|
||||
$pid_file = PWD_PID . '/' . $phone_name . '.pid';
|
||||
|
||||
if (file_exists($pid_file))
|
||||
|
|
|
@ -35,9 +35,9 @@ class Phone extends AbstractDaemon
|
|||
public function __construct(array $phone)
|
||||
{
|
||||
$this->phone = $phone;
|
||||
$this->msg_queue_id = (int) mb_substr($this->phone['number'], 1);
|
||||
$this->msg_queue_id = (int) (QUEUE_ID_PHONE_PREFIX . $this->phone['id']);
|
||||
|
||||
$name = 'RaspiSMS Daemon Phone ' . $this->phone['number'];
|
||||
$name = 'RaspiSMS Daemon Phone ' . $this->phone['id'];
|
||||
$logger = new Logger($name);
|
||||
$logger->pushHandler(new StreamHandler(PWD_LOGS . '/raspisms.log', Logger::DEBUG));
|
||||
$pid_dir = PWD_PID;
|
||||
|
@ -140,6 +140,8 @@ class Phone extends AbstractDaemon
|
|||
|
||||
$message['at'] = $at;
|
||||
|
||||
$message['origin'] = $this->phone['number'];
|
||||
|
||||
$this->logger->info('Try send message : ' . json_encode($message));
|
||||
|
||||
$sended_sms_uid = $this->adapter->send($message['destination'], $message['text'], $message['flash']);
|
||||
|
@ -163,7 +165,7 @@ class Phone extends AbstractDaemon
|
|||
}
|
||||
|
||||
/**
|
||||
* Read smss for a number.
|
||||
* Read smss for a phone.
|
||||
*/
|
||||
private function read_smss()
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ class Sender extends AbstractDaemon
|
|||
|
||||
//Get smss and transmit order to send to appropriate phone daemon
|
||||
$smss = $this->internal_scheduled->get_smss_to_send();
|
||||
$this->transmit_smss($smss); //Add new queues to array of queues
|
||||
$this->transmit_smss($smss); //Add new queue to array of queues
|
||||
|
||||
usleep(0.5 * 1000000);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class Sender extends AbstractDaemon
|
|||
foreach ($smss as $sms)
|
||||
{
|
||||
//If queue not already exists
|
||||
$queue_id = (int) mb_substr($sms['origin'], 1);
|
||||
$queue_id = (int) (QUEUE_ID_PHONE_PREFIX . $sms['id_phone']);
|
||||
if (!msg_queue_exists($queue_id) || !isset($queues[$queue_id]))
|
||||
{
|
||||
$this->queues[$queue_id] = msg_get_queue($queue_id);
|
||||
|
@ -73,7 +73,7 @@ class Sender extends AbstractDaemon
|
|||
'id_user' => $sms['id_user'],
|
||||
'id_scheduled' => $sms['id_scheduled'],
|
||||
'text' => $sms['text'],
|
||||
'origin' => $sms['origin'],
|
||||
'id_phone' => $sms['id_phone'],
|
||||
'destination' => $sms['destination'],
|
||||
'flash' => $sms['flash'],
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue