Note: The client accepts an array with options. The available options are stdin => Optional. If set, should contain an already open stream from where the client will read data (useful to make it interact with fastagi servers or even text files to mock stuff when testing). If not set, stdin will be used by the client. stdout => Optional. Same as stdin but for the output of the client. PHP Version 5
Автор: Marcelo Gornstein (marcelog@gmail.com)
Наследование: extends PAGI\Application\PAGIApplication
Пример #1
0
 public function handle(EventMessage $event)
 {
     if ($event instanceof \PAMI\Message\Event\AsyncAGIEvent) {
         if ($event->getSubEvent() == 'Start') {
             switch ($pid = pcntl_fork()) {
                 case 0:
                     $logger = \Logger::getLogger(__CLASS__);
                     $this->_client = new ClientImpl($this->_pamiOptions);
                     $this->_client->open();
                     $agi = new \PAMI\AsyncAgi\AsyncClientImpl(array('pamiClient' => $this->_client, 'asyncAgiEvent' => $event));
                     $app = new MyPAGIApplication(array('pagiClient' => $agi));
                     $app->init();
                     $app->run();
                     //$agi->indicateProgress();
                     //$agi->answer();
                     //$agi->streamFile('welcome');
                     //$agi->playCustomTones(array("425/50","0/50"));
                     //sleep(5);
                     //$agi->indicateCongestion(10);
                     //$agi->hangup();
                     $this->_client->close();
                     echo "Application finished\n";
                     exit(0);
                     break;
                 case -1:
                     echo "Could not fork application\n";
                     break;
                 default:
                     echo "Forked Application\n";
                     break;
             }
         }
     }
 }
Пример #2
0
<?php

require_once 'PAGI/Autoloader/Autoloader.php';
PAGI\Autoloader\Autoloader::register();
require_once __DIR__ . '/../quickstart/MyPAGIApplication.php';
$variables = array('request' => 'request.php', 'channel' => 'SIP/blah-00803890', 'language' => 'ar', 'type' => 'SIP', 'uniqueid' => '1330012581.77', 'version' => '1.6.0.9', 'callerid' => '40', 'calleridname' => 'Admin', 'callingpres' => '1', 'callingani2' => '0', 'callington' => '0', 'callingtns' => '0', 'dnid' => '55555555', 'rdnis' => 'unknown', 'context' => 'default', 'extension' => '55555555', 'priority' => '1', 'enhanced' => '0.0', 'accountcode' => '', 'threadid' => '1095317840');
$mock = new PAGI\Client\Impl\MockedClientImpl(array('log4php.properties' => __DIR__ . '/../quickstart/log4php.properties', 'variables' => $variables));
$mock->assert('sayDigits', array('12345', '12#'))->assert('sayNumber', array('12345', '12#'))->onSayDigits(true, '1')->onSayNumber(true, '2')->onGetData(false)->onGetOption(true, '4')->onStreamFile(true, '#')->onChannelStatus(PAGI\Client\ChannelStatus::LINE_UP)->onChannelStatus(PAGI\Client\ChannelStatus::LINE_BUSY)->onGetVariable(true, 123)->onGetFullVariable(true, 456)->onGetFullVariable(true, 789)->onGetFullVariable(true, 'asd')->onGetFullVariable(true, '1')->onGetFullVariable(true, '2')->onGetFullVariable(true, '3')->onGetFullVariable(true, '4')->onGetFullVariable(true, '5')->onGetFullVariable(true, '6')->onGetFullVariable(true, '1')->onGetFullVariable(true, '2')->onGetFullVariable(true, '3')->onGetFullVariable(true, '4')->onGetFullVariable(true, '5')->onGetFullVariable(true, '6')->onGetFullVariable(true, '1')->onGetFullVariable(true, '2')->onGetFullVariable(true, '3')->onGetFullVariable(true, '4')->onGetFullVariable(true, '5')->onDial(true, 'name', 'number', '20', 'ANSWER', '#asd')->onSayPhonetic(true, '2')->onSayAlpha(true, '3')->onSayTime(true, '4')->onSayDateTime(true, '5')->onSayDate(true, '6')->onWaitDigit(true, '7')->onWaitDigit(true, '7')->onRecord(true, false, '#', 1000);
$app = new MyPAGIApplication(array('pagiClient' => $mock));
$app->init();
$app->run();
$app->shutdown();