PAMI\Client\Impl\ClientImpl::process PHP Method

process() public method

Main processing loop. Also called from send(), you should call this in your own application in order to continue reading events and responses from ami.
public process ( )
    public function process()
    {
        $msgs = $this->getMessages();
        foreach ($msgs as $aMsg) {
            $this->logger->debug('------ Received: ------ ' . "\n" . $aMsg . "\n\n");
            $resPos = strpos($aMsg, 'Response:');
            $evePos = strpos($aMsg, 'Event:');
            if ($resPos !== false && ($resPos < $evePos || $evePos === false)) {
                $response = $this->messageToResponse($aMsg);
                $this->incomingQueue[$response->getActionId()] = $response;
            } elseif ($evePos !== false) {
                $event = $this->messageToEvent($aMsg);
                $response = $this->findResponse($event);
                if ($response === false || $response->isComplete()) {
                    $this->dispatch($event);
                } else {
                    $response->addEvent($event);
                }
            } else {
                // broken ami.. sending a response with events without
                // Event and ActionId
                $bMsg = 'Event: ResponseEvent' . "\r\n";
                $bMsg .= 'ActionId: ' . $this->lastActionId . "\r\n" . $aMsg;
                $event = $this->messageToEvent($bMsg);
                $response = $this->findResponse($event);
                $response->addEvent($event);
            }
            $this->logger->debug('----------------');
        }
    }

Usage Example

コード例 #1
0
ファイル: Client.php プロジェクト: thomasvargiu/pami-module
 /**
  * Main processing loop. Also called from send(), you should call this in
  * your own application in order to continue reading events and responses
  * from ami.
  *
  * @return $this
  */
 public function process()
 {
     $results = $this->getEventManager()->trigger(__FUNCTION__ . '.pre', $this);
     if ($results->stopped()) {
         return $this;
     }
     $this->connection->process();
     $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this);
     return $this;
 }
All Usage Examples Of PAMI\Client\Impl\ClientImpl::process