Browse Source

validando se o agente foi desconectado

websocket
lucas cardoso 3 years ago
parent
commit
fbf4e25f6d
  1. 16
      app/Models/SupervisorModel.php
  2. 7
      service/ServiceSupervisorPBx.php
  3. 2
      tests/test_services.php

16
app/Models/SupervisorModel.php

@ -103,6 +103,18 @@ class SupervisorModel extends Model
return $this->read($this->query, $data)->fetchAll();
}
public function findAllAgentesPBX($queue = null)
{
$data = [];
$this->query = "SELECT * FROM pbx_supervisor_agentes WHERE 1=1 ";
if ($queue) {
$this->query .= " AND fila = :queue ";
$data['queue'] = $queue;
}
return $this->read($this->query, $data)->fetchAll();
}
public function findByAgent($matricula)
{
$this->query = "SELECT * FROM " . self::USUARIOS . " WHERE matricula = :matricula;";
@ -322,10 +334,10 @@ class SupervisorModel extends Model
return $this->update($this->query, $data);
}
public function deleteAgent($matricula)
public function deleteAgentPbx($matricula)
{
$data = [];
$this->query = "DELETE FROM " . self::SUPERVISOR_AGENTE . " WHERE matricula = :matricula";
$this->query = "DELETE FROM pbx_supervisor_agentes WHERE matricula = :matricula";
$data['matricula'] = $matricula;
return $this->delete($this->query, $data);
}

7
service/ServiceSupervisorPBx.php

@ -23,6 +23,13 @@ class ServiceSupervisorPBx implements IService
$this->atualizaTabelaSupervisor($agente, $agentPbx);
}
}
$agentesPbx = $this->supervisorModel->findAllAgentesPBX();
foreach ($agentesPbx as $key => $pbx) {
$age = $this->supervisorModel->findAgentByMatricula($pbx->matricula);
if (empty($age)) {
$this->supervisorModel->deleteAgentPbx($pbx->matricula);
}
}
}
function atualizaTabelaSupervisor($agente, $agentePbx)

2
tests/test_services.php

@ -17,5 +17,5 @@ while (true) {
$sevice_timeout->run();
echo "executar servce_queue \n";
$servce_queue->run();
sleep(10);
sleep(3);
}
Loading…
Cancel
Save