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
43 lines
1.1 KiB
<?php |
|
|
|
namespace websocket; |
|
|
|
use WebSocket\Client as Testess; |
|
|
|
class WsInterface |
|
{ |
|
private $client; |
|
|
|
function enviaMsg($msg) |
|
{ |
|
if (!empty($msg)) { |
|
$this->client = new Testess("ws://192.168.115.65:8080/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 (\Exception $th) { |
|
logger('monitora')->info($th->getMessage(), debug_backtrace()); |
|
} |
|
} |
|
} |