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.

43 lines
1.1 KiB

3 years ago
<?php
namespace websocket;
use WebSocket\Client as Testess;
3 years ago
class WsInterface
{
private $client;
function enviaMsg($msg)
{
if (!empty($msg)) {
$this->client = new Testess("ws://192.168.115.65:8090/ws");
$this->client->send($msg);
$this->client->close();
return null;
3 years ago
}
}
3 years ago
function enviaActions($msg, $tipo, $matricula = null, $uniqueid = null)
3 years ago
{
try {
$mensagem = [];
$mensagem["event"] = [
"type" => 'actions',
"contact" => [
"name" => 'Sistema',
"number" => '0'
],
"mensagem" => [
"type" => utf8_encode($tipo),
"dst" => utf8_encode($matricula),
"uniqueid" => utf8_encode($uniqueid),
3 years ago
"content" => utf8_encode($msg)
],
];
return json_encode($mensagem);
} catch (\Exception $th) {
3 years ago
logger('monitora')->info($th->getMessage(), debug_backtrace());
}
}
3 years ago
}