Browse Source

alterando ws para local e adicionando func convetws

twilio
lucas cardoso 3 years ago
parent
commit
9d936241af
  1. 31
      websocket/WsInterface.php
  2. 2
      websocket/websocket.php

31
websocket/WsInterface.php

@ -11,7 +11,7 @@ class WsInterface
function enviaMsg($msg)
{
if (!empty($msg)) {
$this->client = new Testess("ws://192.168.115.65:8080/ws");
$this->client = new Testess("ws://127.0.0.1:8080/ws");
$this->client->send($msg);
$this->client->close();
return null;
@ -40,4 +40,33 @@ class WsInterface
logger('monitora')->info($th->getMessage(), debug_backtrace());
}
}
public function convertToWebsocket($content, $matricula = '', $uniqueid, $type, $name, $number, $data, $idProvedor, $mimetype, $file_name = null, $channel)
{
if ($number) {
$mensagem = [];
$mensagem["event"] = [
"type" => "mensagem",
"contact" => [
"name" => $name,
"number" => $number,
"matricula" => ''
],
"mensagem" => [
"type" => $type,
"content" => $content,
"id_provedor" => $idProvedor,
"dst" => $matricula,
"uniqueid" => $uniqueid,
"media" => $channel,
"file_name" => $file_name,
"datetime" => $data,
"status" => "sent",
'mimetype' => $mimetype
]
];
return json_encode($mensagem);
}
return null;
}
}

2
websocket/websocket.php

@ -6,7 +6,7 @@ include __DIR__ . '/../includes/config.php';
use websocket\Servidorsocket;
try {
$app = new Ratchet\App('192.168.115.65', 8080, '0.0.0.0');
$app = new Ratchet\App('127.0.0.1', 8080, '0.0.0.0');
$app->route('/ws', new Servidorsocket(), array('*'));
$app->run();
} catch (\Exception $th) {

Loading…
Cancel
Save