fix counting tick for read phone
This commit is contained in:
parent
cc188f3118
commit
c69527a5ad
|
@ -21,6 +21,7 @@ class Phone extends AbstractDaemon
|
|||
{
|
||||
private $max_inactivity = 5 * 60;
|
||||
private $read_delay = 20 / 0.5;
|
||||
private $read_tick = 0;
|
||||
private $msg_queue;
|
||||
private $msg_queue_id;
|
||||
private $webhook_queue;
|
||||
|
@ -57,7 +58,7 @@ class Phone extends AbstractDaemon
|
|||
{
|
||||
usleep(0.5 * 1000000); //Micro sleep for perfs
|
||||
|
||||
$read_tick = ($read_tick ?? 0) + 1; //Count tick
|
||||
$this->read_tick += 1;
|
||||
|
||||
$this->bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, 'UTF8');
|
||||
|
||||
|
@ -65,11 +66,12 @@ class Phone extends AbstractDaemon
|
|||
$this->send_smss();
|
||||
|
||||
//Read only every x ticks (x/2 seconds) to prevent too many call
|
||||
if ($read_tick >= $this->read_delay)
|
||||
if ($this->read_tick >= $this->read_delay)
|
||||
{
|
||||
//Read received smss
|
||||
$this->read_smss();
|
||||
$read_tick = 0;
|
||||
$this->logger->info('Read smss' );
|
||||
$this->read_tick = 0;
|
||||
}
|
||||
|
||||
//Stop after 5 minutes of inactivity to avoid useless daemon
|
||||
|
|
Loading…
Reference in New Issue