Browse Source

add script para rodar testes

websocket
lucascardo12 3 years ago
parent
commit
44058a1ffe
  1. 16
      tests/test_services.php
  2. 85
      tests/teste_timeout.php

16
tests/test_services.php

@ -0,0 +1,16 @@
<?php
use service\ServiceQueue;
use service\ServiceTimeout;
use websocket\WsInterface;
require __DIR__ . '/../vendor/autoload.php';
include __DIR__ . '/../includes/config.php';
$sevice_timeout = new ServiceTimeout();
$servce_queue = new ServiceQueue();
while (true) {
$sevice_timeout->run();
$servce_queue->run();
sleep(30);
}

85
tests/teste_timeout.php

@ -1,85 +0,0 @@
<?php
use app\Controllers\MessageController;
use app\Core\Commands;
use app\Models\Atendimento;
use app\Models\Message;
use app\Models\NotificaMedia;
use app\Providers\Positus;
require __DIR__ . '/../vendor/autoload.php';
include __DIR__ . '/../includes/config.php';
class ServiceTimeout
{
private $atendimentos;
private $timeout_agent_alert = (CONF_WHATSAPP_TIMEOUT_AGENT_AVISO / 60);
private $timeout_agent_desconexao = (CONF_WHATSAPP_TIMEOUT_AGENT_DESCONEXAO / 60);
private $timeout_agent_classificacao = (CONF_WHATSAPP_TIMEOUT_AGENT_CLASSIFICACAO / 60);
private $mensagem;
private $positus;
private $message;
private $notificaMedia;
private $mensages;
private $command;
function __construct()
{
$this->positus = new Positus();
$this->message = new MessageController();
$this->notificaMedia = new NotificaMedia();
$this->mensages = new Message();
$this->atendimentos = new Atendimento();
$this->command = new Commands();
$this->mensagem = [
"ALERTA_INATIVIDADE" => "Você será desconectado em " . ($this->timeout_agent_desconexao - $this->timeout_agent_alert) . " minutos, para permanecer em atendimento clique em '/presente'",
"ALERTA_DESCONECTADO" => "Você foi desconectado por inatividade!",
"ALERTA_CLIENTE" => "Olá, como podemos lhe ajudar!",
"TIMEOUT_CLIENT_INATIVIDADE" => "O tempo da conversa foi expirado, por favor volte novamente a fila para um novo atendimento!",
"TALK_FINISHED" => "O atendimento foi finalizado!",
"TALK_ALERT_FINISH" => "Por favor, volte a comunicação com nosso atendimento em 1 minuto ou atendimento será encerrado!"
];
}
public function inicia()
{
$this->command->setApi($this->positus);
while (true) {
$atendiss = $this->atendimentos->findAtenEmAberto();
foreach ($atendiss as $value) {
$this->timeoutCliente($value->uniqueid, $value->cliente_id);
}
sleep(60);
}
}
private function timeoutCliente($uniqueid, $client)
{
echo "unique: $uniqueid - client: $client \n";
if ($this->message->timeoutTalk($uniqueid) == 'FINISH') {
$this->positus->enviarMsg($client, $this->mensagem['TIMEOUT_CLIENT_INATIVIDADE']);
$this->command->finalizar($client);
return null;
}
if ($this->message->timeoutTalk($uniqueid, $client) == 'ALERT') {
$msg = $this->mensages->findLastMessage($uniqueid);
$retorno = $this->notificaMedia->verificaNotifica(
$uniqueid,
$client,
utf8_encode($this->mensagem['TALK_ALERT_FINISH']) . $msg->id
);
if ($retorno->quant == 0) {
$this->notificaMedia->addNotifica(
$uniqueid,
$client,
utf8_encode($this->mensagem['TALK_ALERT_FINISH']) . $msg->id
);
$this->positus->enviarMsg(
$client,
$this->mensagem['TALK_ALERT_FINISH']
);
}
}
}
}
$sevice_timeout = new ServiceTimeout();
$sevice_timeout->inicia();
Loading…
Cancel
Save