/**
  * Constructor.
  *
  * @param string $rawContent Literal message as received from ami.
  *
  * @return void
  */
 public function __construct($rawContent)
 {
     parent::__construct($rawContent);
 }
Beispiel #2
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;
             }
         }
     }
 }
 /**
  * Forward PAMI event to EventManager.
  *
  * @param EventMessage $e PAMI event
  */
 public function handle(EventMessage $e)
 {
     $eventPrefix = 'event.';
     $eventName = $eventPrefix . $e->getName();
     $event = new PamiEvent();
     $event->setName($eventName);
     $event->setTarget($this->client);
     $event->setEvent($e);
     $this->client->getEventManager()->triggerEvent($event);
 }
Beispiel #4
0
 public function handle(EventMessage $event)
 {
     //This Handler will print the incoming message.
     echo "Message Received from :" . $event->getFrom() . " \n";
     if ($event->getContentEncoding() == 'base64') {
         echo base64_decode($event->getContent());
     } else {
         echo 'Unrecognized encoding - printing message in this encoding :  ';
         $event->getContentEncoding();
         echo '\\n Message:  ';
         $event->getContent();
     }
 }
Beispiel #5
0
 public static function getMessageKeys()
 {
     return array_merge(parent::getMessageKeys(), ['privilege', 'channel', 'calleridnum', 'calleridname', 'context', 'accountcode', 'uniqueid', 'linkedid', 'destchannel', 'destuniqueid', 'dialstring']);
 }
 /**
  * Handles pami events.
  *
  * @param EventMessage $event
  *
  * @return void
  */
 public function handle(EventMessage $event)
 {
     if ($event instanceof \PAMI\Message\Event\AsyncAGIEvent) {
         if ($event->getCommandId() == $this->_lastCommandId) {
             $this->_lastAgiResult = trim($event->getResult());
         }
     }
 }
Beispiel #7
0
 /**
  * Constructor.
  *
  * @param string $rawContent Literal message as received from ami.
  *
  * @return void
  */
 public function __construct($rawContent)
 {
     parent::__construct($rawContent);
     $this->setKey('Env', urldecode($this->getEnvironment()));
     $this->setKey('Result', urldecode($this->getResult()));
 }
Beispiel #8
0
 /**
  * Adds an event to this response.
  *
  * @param EventMessage $event Child event to add.
  *
  * @return void
  */
 public function addEvent(EventMessage $event)
 {
     $this->events[] = $event;
     if (stristr($event->getEventList(), 'complete') !== false || stristr($event->getName(), 'complete') !== false || stristr($event->getName(), 'DBGetResponse') !== false) {
         $this->completed = true;
     }
 }
Beispiel #9
0
 public static function getMessageKeys()
 {
     return array_merge(parent::getMessageKeys(), ['privilege', 'channel', 'calleridnum', 'calleridname', 'uniqueid', 'cause', 'causetext']);
 }