Update: First test call Asteriks vs Swoole
parent
0abaaed9cf
commit
272c662d82
|
@ -2960,10 +2960,6 @@ class AGIEntrada
|
|||
// ...
|
||||
|
||||
$response = $this->agiRunCmd('EXEC NOOP HITAGI');
|
||||
|
||||
// termina
|
||||
// return;
|
||||
|
||||
$response = $this->agiRunCmd('ANSWER');
|
||||
$response = $this->agiRunCmd('EXEC WAIT 1');
|
||||
$response = $this->agiRunCmd('EXEC PLAYBACK beep');
|
||||
|
|
|
@ -9,6 +9,7 @@ use Swoole\Server;
|
|||
|
||||
Runtime::enableCoroutine();
|
||||
$table = new Table(1024);
|
||||
$table->column('agi', Swoole\Table::TYPE_INT);
|
||||
$table->column('data', Swoole\Table::TYPE_STRING, 65536);
|
||||
$table->column('agi_arg', Swoole\Table::TYPE_STRING, 65536);
|
||||
$table->create();
|
||||
|
@ -30,7 +31,7 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
|
|||
|
||||
if (!is_array($table_data)) {
|
||||
// FIRST CONNECTION
|
||||
echo 'LOG ======> data (FIRST): ' . PHP_EOL . $data . PHP_EOL;
|
||||
echo 'LOG ======> Receive data (FIRST): ' . PHP_EOL . $data . PHP_EOL;
|
||||
$table_data = [
|
||||
'data' => $data,
|
||||
'agi_arg' => json_encode([])
|
||||
|
@ -38,7 +39,7 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
|
|||
$server->table->set($fd, $table_data);
|
||||
} else {
|
||||
// ALREADY CONNECTED
|
||||
echo 'LOG ======> data (MORE): ' . PHP_EOL . $data . PHP_EOL;
|
||||
echo 'LOG ======> Receive data (MORE): ' . PHP_EOL . $data . PHP_EOL;
|
||||
$table_data['data'] .= $data;
|
||||
$server->table->set($fd, $table_data);
|
||||
}
|
||||
|
@ -61,7 +62,17 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
|
|||
$table_data['agi_arg'] = json_encode($argv);
|
||||
$server->table->set($fd, $table_data);
|
||||
|
||||
if (isset($argv['1'])) {
|
||||
$server_close = false;
|
||||
if (strpos($table_data['data'], 'HANGUP') !== false) {
|
||||
$server_close = true;
|
||||
}
|
||||
|
||||
if ((isset($argv['1'])) && ($table_data['agi'] != 1)) {
|
||||
|
||||
$table_data = [
|
||||
'agi' => 1
|
||||
];
|
||||
$server->table->set($fd, $table_data);
|
||||
|
||||
$fgId = $argv[1]; // Numero do DID
|
||||
// $hostname = $argv[2];
|
||||
|
@ -92,7 +103,23 @@ $server->on("receive", function ($server, $fd, $reactor_id, $data) {
|
|||
);
|
||||
$agi->run();
|
||||
|
||||
// agiRunCmdWrapper($fd,$server)('EXEC NOOP HITAGI2');
|
||||
// agiRunCmdWrapper($fd,$server)('ANSWER');
|
||||
// agiRunCmdWrapper($fd,$server)('EXEC WAIT 1');
|
||||
// agiRunCmdWrapper($fd,$server)('EXEC PLAYBACK beep');
|
||||
// agiRunCmdWrapper($fd,$server)('EXEC WAIT 1');
|
||||
// agiRunCmdWrapper($fd,$server)('GET VARIABLE CALLERID(all)');
|
||||
// // agiRunCmdWrapper($fd,$server)('HANGUP');
|
||||
|
||||
$server_close = true;
|
||||
|
||||
}
|
||||
|
||||
if ($server_close) {
|
||||
$server->close($fd);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$server->on("close", function ($server, $fd) {
|
||||
|
|
Loading…
Reference in New Issue