Skip to content

Instantly share code, notes, and snippets.

@GianpaMX
Created May 21, 2012 20:46
Show Gist options
  • Save GianpaMX/2764571 to your computer and use it in GitHub Desktop.
Save GianpaMX/2764571 to your computer and use it in GitHub Desktop.
Esbozo del Listener
<?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