-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransfer.php
More file actions
47 lines (36 loc) · 1.45 KB
/
transfer.php
File metadata and controls
47 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
use libspech\Cli\cli;
include (is_dir('libspech' ? 'libspech/' : ''))."plugins/autoloader.php";;
\co\run(function () {
$fileConnections = file_get_contents('/home/lotus/projetos/spechshop-discadora/connections.json');
$connections = json_decode($fileConnections, true);
$transferTo = 'lotus';
if (!isset($connections[$transferTo])) {
return \libspech\Cli\cli::pcl("Transfer destination '$transferTo' not found in connections.json", 'bold_red');
}
$address = $connections[$transferTo]['address'];
$port = $connections[$transferTo]['port'];
$phone = new \libspech\Sip\trunkController($transferTo, '', $address, $port);
$phone->setCallerId('discadora');
$phone->mountLineCodecSDP('PCMA/8000');
$phone->defineAudioFile('extra/assets/music.wav');
$phone->onAnswer(function (\libspech\Sip\trunkController $phone) {
$phone->receiveMedia();
$phone->defineAudioFile('extra/assets/music.wav');
\Swoole\Coroutine::sleep(3);
//$phone->stopAudioFile();
$phone->send2833('9');
\Swoole\Coroutine::sleep(10);
$phone->bye();
});
$phone->onFailed(function ($message) {
cli::pcl("Chamada falhou: $message", "bold_red");
});
$phone->onHangup(function () {
cli::pcl("Chamada encerrada", "bold_red");
});
$phone->onKeyPress(function ($event, $peer) {
cli::pcl("DTMF: " . $event, 'bold_green');
});
$phone->call('lotus');
});