Software

PAMI

Tutorial

For an in-depth tutorial, read this.

Quickstart

$options = array(
    'log4php.properties' => RESOURCES_DIR . DIRECTORY_SEPARATOR . 'log4php.properties',
    'host' => '2.3.4.5',
    'scheme' => 'tcp://',
    'port' => 9999,
    'username' => 'asd',
    'secret' => 'asd',
    'connect_timeout' => 10,
    'read_timeout' => 10
);
$client = new \PAMI\Client\Impl\ClientImpl($options);

// Registering a closure
$client->registerEventListener(function ($event) {
});

// Register a specific method of an object for event listening
$client->registerEventListener(array($listener, 'handle'));

// Register an IEventListener:
$client->registerEventListener($listener);

Using Predicates to control events flow

A second (optional) argument can be used when registering the event listener: a closure that will be evaluated before calling the callback. The callback will be called only if this predicate returns true:

use PAMI\Message\Event\DialEvent;

$client->registerEventListener(
    array($listener, 'handleDialStart'),
    function ($event) {
        return $event instanceof DialEvent && $event->getSubEvent() == 'Begin';
    })
);

Examples

NOTE: You will need to have log4php installed and in your include path (the src/main/php directory of the source distribution).

For a very raw quickstart: https://github.com/marcelog/PAMI/tree/master/docs/examples for all (and full) examples.

Also, for a more elegant example, mixing Ding and PAMI, Please see https://github.com/marcelog/AsterTrace

Also, you might want to look at this article.