-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathevents.php
More file actions
27 lines (20 loc) · 773 Bytes
/
events.php
File metadata and controls
27 lines (20 loc) · 773 Bytes
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
<?php
require __DIR__ . '/../vendor/autoload.php';
$factory = new Clue\React\Ami\Factory();
$target = isset($argv[1]) ? $argv[1] : 'name:password@localhost';
$factory->createClient($target)->then(
function (Clue\React\Ami\Client $client) {
echo 'Client connected ' . PHP_EOL;
$sender = new Clue\React\Ami\ActionSender($client);
$sender->events(true);
$client->on('close', function() {
echo 'Connection closed' . PHP_EOL;
});
$client->on('event', function (Clue\React\Ami\Protocol\Event $event) {
echo 'Event: ' . $event->getName() . ': ' . json_encode($event->getFields()) . PHP_EOL;
});
},
function (Exception $error) {
echo 'Connection error: ' . $error;
}
);