Created
May 21, 2012 20:46
-
-
Save GianpaMX/2764571 to your computer and use it in GitHub Desktop.
Esbozo del Listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'PAMI/Autoloader/Autoloader.php'; | |
PAMI\Autoloader\Autoloader::register(); | |
ini_set('include_path', implode(PATH_SEPARATOR, array( | |
'phar://pami.phar', '/usr/share/php/log4php', ini_get('include_path') | |
))); | |
use PAMI\Client\Impl\ClientImpl as PamiClient; | |
use PAMI\Message\Event\EventMessage; | |
use PAMI\Listener\IEventListener; | |
$pamiClientOptions = array( | |
'host' => '172.17.0.104', | |
'scheme' => 'tcp://', | |
'port' => 5038, | |
'username' => 'admin', | |
'secret' => 'qwerty', | |
'connect_timeout' => 10000, | |
'read_timeout' => 10000 | |
); | |
$pamiClient = new PamiClient($pamiClientOptions); | |
// Open the connection | |
$pamiClient->open(); | |
$pamiClient->registerEventListener(function (EventMessage $event) { | |
var_dump($event); | |
}); | |
$running = true; | |
// Main loop | |
while($running) { | |
$pamiClient->process(); | |
usleep(1000); | |
} | |
// Close the connection | |
$pamiClient->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment