示例#1
0
文件: Ack.php 项目: Koulio/OpenZIS
 public function processAck($m)
 {
     $dom = $this->dom;
     $headerNode = $m->headerNode;
     $msgId = $m->msgId;
     $agentSourceId = $m->sourceId;
     #        $msgId           = $headerNode->getElementsByTagName('SIF_MsgId')->item(0)->nodeValue;
     #        $agentSourceId   = $headerNode->getElementsByTagName('SIF_SourceId')->item(0)->nodeValue;
     $originalMsgId = $dom->getElementsByTagName('SIF_OriginalMsgId')->item(0)->nodeValue;
     $timestamp = $headerNode->getElementsByTagName('SIF_Timestamp')->item(0)->nodeValue;
     $status = $dom->getElementsByTagName('SIF_Status');
     $status = $status->item(0)->nodeValue;
     $validSourceId = Agent::checkSourceId($agentSourceId);
     if (!$validSourceId) {
         RegisterError::invalidSourceId($agentSourceId, $msgId);
     } else {
         $agent = new Agent($agentSourceId);
         if ($agent->isRegistered()) {
             if ($status == 1) {
                 $agent->unFreezeAgent();
                 $this->updateMessageQueue($agent, $originalMsgId, $msgId);
             } else {
                 if ($status == 3) {
                     //done processing
                     if ($originalMsgId == $agent->frozenMsgId) {
                         $agent->unFreezeAgent();
                         $this->updateMessageQueue($agent, $originalMsgId, $msgId);
                     } else {
                         GeneralError::EventACKError($this->xml);
                     }
                 } else {
                     if ($status == 2) {
                         //Intermediate wait for final
                         $agent->freezeAgent();
                         $agent->setFrozenMsgId($originalMsgId);
                         $timestamp = Utility::createTimestamp();
                         $msgId_u = Utility::createMessageId();
                         XmlHelper::buildSuccessMessage($msgId_u, $timestamp, $agent->sourceId, $msgId, 0, $originalMsg = null, $desc = null);
                     }
                 }
             }
         } else {
             RegisterError::notRegisteredError($agentSourceId, $msgId);
         }
     }
 }