| 
1 | 1 | <?php  | 
2 | 2 | 
 
  | 
3 |  | -use Clue\React\Ami\Factory;  | 
4 |  | -use Clue\React\Ami\Client;  | 
5 |  | -use Clue\React\Ami\ActionSender;  | 
6 |  | -use Clue\React\Ami\Protocol\Response;  | 
7 | 3 | use React\EventLoop\Loop;  | 
8 | 4 | 
 
  | 
9 | 5 | require __DIR__ . '/../vendor/autoload.php';  | 
10 | 6 | 
 
  | 
11 |  | -$factory = new Factory();  | 
 | 7 | +$factory = new Clue\React\Ami\Factory();  | 
12 | 8 | 
 
  | 
13 | 9 | $target = isset($argv[1]) ? $argv[1] : 'name:password@localhost';  | 
14 | 10 | 
 
  | 
15 |  | -$factory->createClient($target)->then(function (Client $client) {  | 
 | 11 | +$factory->createClient($target)->then(function (Clue\React\Ami\Client $client) {  | 
16 | 12 |     echo 'Client connected. Use STDIN to send CLI commands via asterisk AMI.' . PHP_EOL;  | 
17 |  | -    $sender = new ActionSender($client);  | 
 | 13 | +    $sender = new Clue\React\Ami\ActionSender($client);  | 
18 | 14 | 
 
  | 
19 | 15 |     $sender->events(false);  | 
20 | 16 | 
 
  | 
21 |  | -    $sender->listCommands()->then(function (Response $response) {  | 
 | 17 | +    $sender->listCommands()->then(function (Clue\React\Ami\Protocol\Response $response) {  | 
22 | 18 |         echo 'Commands: ' . implode(', ', array_keys($response->getFields())) . PHP_EOL;  | 
23 | 19 |     });  | 
24 | 20 | 
 
  | 
 | 
33 | 29 |         echo '<' . $line . PHP_EOL;  | 
34 | 30 | 
 
  | 
35 | 31 |         $sender->command($line)->then(  | 
36 |  | -            function (Response $response) {  | 
 | 32 | +            function (Clue\React\Ami\Protocol\Response $response) {  | 
37 | 33 |                 echo $response->getCommandOutput() . PHP_EOL;  | 
38 | 34 |             },  | 
39 | 35 |             function (Exception $error) use ($line) {  | 
40 | 36 |                 echo 'Error executing "' . $line . '": ' . $error->getMessage() . PHP_EOL;  | 
41 | 37 |             }  | 
42 | 38 |         );  | 
43 | 39 |     });  | 
44 |  | -}, 'var_dump');  | 
 | 40 | +}, function (Exception $error) {  | 
 | 41 | +    echo 'Connection error: ' . $error;  | 
 | 42 | +});  | 
0 commit comments