You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace websocket;
|
|
|
|
|
|
|
|
use WebSocket\Client;
|
|
|
|
|
|
|
|
class WsInterface
|
|
|
|
{
|
|
|
|
private $client;
|
|
|
|
|
|
|
|
function enviaMsg($msg)
|
|
|
|
{
|
|
|
|
if (!empty($msg)) {
|
|
|
|
$this->client = new Client("ws://192.168.115.65:8090/ws");
|
|
|
|
$this->client->send($msg);
|
|
|
|
$this->client->close();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function enviaActions($msg, $tipo, $matricula = null, $uniqueid = null)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$mensagem = [];
|
|
|
|
$mensagem["event"] = [
|
|
|
|
"type" => 'actions',
|
|
|
|
"contact" => [
|
|
|
|
"name" => 'Sistema',
|
|
|
|
"number" => '0'
|
|
|
|
],
|
|
|
|
"mensagem" => [
|
|
|
|
"type" => utf8_encode($tipo),
|
|
|
|
"dst" => utf8_encode($matricula),
|
|
|
|
"uniqueid" => utf8_encode($uniqueid),
|
|
|
|
"content" => utf8_encode($msg)
|
|
|
|
],
|
|
|
|
];
|
|
|
|
return json_encode($mensagem);
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
logger('monitora')->info($th->getMessage(), debug_backtrace());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|