Esempio n. 1
0
 /**
  * Routes incoming XMPP data to appropriate handlers
  */
 function handler($payload)
 {
     if ($payload == '' && $this->mode == 'cli') {
         return '';
     }
     if ($payload != '' && $this->mode == 'cgi') {
         $this->log("[[XMPPGet]] \n" . $payload, 4);
     }
     $payload = $this->executePlugin('jaxl_pre_handler', $payload);
     $xmls = JAXLUtil::splitXML($payload);
     $pktCnt = count($xmls);
     $this->totalRcvdPkt += $pktCnt;
     $buffer = array();
     foreach ($xmls as $pktNo => $xml) {
         if ($pktNo == $pktCnt - 1) {
             if (substr($xml, -1, 1) != '>') {
                 $this->buffer .= $xml;
                 break;
             }
         }
         if (substr($xml, 0, 7) == '<stream') {
             $arr = $this->xml->xmlize($xml);
         } else {
             $arr = JAXLXml::parse($xml, $this->getSXE);
         }
         if ($arr === false) {
             $this->buffer .= $xml;
             continue;
         }
         switch (true) {
             case isset($arr['stream:stream']):
                 XMPPGet::streamStream($arr['stream:stream'], $this);
                 break;
             case isset($arr['stream:features']):
                 XMPPGet::streamFeatures($arr['stream:features'], $this);
                 break;
             case isset($arr['stream:error']):
                 XMPPGet::streamError($arr['stream:error'], $this);
                 break;
             case isset($arr['failure']):
                 XMPPGet::failure($arr['failure'], $this);
                 break;
             case isset($arr['proceed']):
                 XMPPGet::proceed($arr['proceed'], $this);
                 break;
             case isset($arr['challenge']):
                 XMPPGet::challenge($arr['challenge'], $this);
                 break;
             case isset($arr['success']):
                 XMPPGet::success($arr['success'], $this);
                 break;
             case isset($arr['presence']):
                 $buffer['presence'][] = $arr['presence'];
                 break;
             case isset($arr['message']):
                 $buffer['message'][] = $arr['message'];
                 break;
             case isset($arr['iq']):
                 $this->payloadRaw = $arr['xml'];
                 XMPPGet::iq($arr['iq'], $this);
                 break;
             default:
                 $jaxl->log("[[XMPPGet]] \nUnrecognized payload received from jabber server...");
                 throw new JAXLException("[[XMPPGet]] Unrecognized payload received from jabber server...");
                 break;
         }
     }
     if (isset($buffer['presence'])) {
         XMPPGet::presence($buffer['presence'], $this);
     }
     if (isset($buffer['message'])) {
         XMPPGet::message($buffer['message'], $this);
     }
     unset($buffer);
     $this->executePlugin('jaxl_post_handler', $payload);
     return $payload;
 }
Esempio n. 2
0
 /**
  * Routes incoming XMPP data to appropriate handlers
  */
 function handler($payload)
 {
     $this->log("[[XMPPGet]] \n" . $payload, 4);
     $buffer = array();
     $payload = JAXLPlugin::execute('jaxl_pre_handler', $payload, $this);
     $xmls = JAXLUtil::splitXML($payload);
     $pktCnt = count($xmls);
     foreach ($xmls as $pktNo => $xml) {
         if ($pktNo == $pktCnt - 1) {
             if (substr($xml, -1, 1) != '>') {
                 $this->buffer = $xml;
                 break;
             }
         }
         if (substr($xml, 0, 7) == '<stream') {
             $arr = $this->xml->xmlize($xml);
         } else {
             $arr = JAXLXml::parse($xml);
         }
         switch (true) {
             case isset($arr['stream:stream']):
                 XMPPGet::streamStream($arr['stream:stream'], $this);
                 break;
             case isset($arr['stream:features']):
                 XMPPGet::streamFeatures($arr['stream:features'], $this);
                 break;
             case isset($arr['stream:error']):
                 XMPPGet::streamError($arr['stream:error'], $this);
                 break;
             case isset($arr['failure']):
                 XMPPGet::failure($arr['failure'], $this);
                 break;
             case isset($arr['proceed']):
                 XMPPGet::proceed($arr['proceed'], $this);
                 break;
             case isset($arr['challenge']):
                 XMPPGet::challenge($arr['challenge'], $this);
                 break;
             case isset($arr['success']):
                 XMPPGet::success($arr['success'], $this);
                 break;
             case isset($arr['presence']):
                 $buffer['presence'][] = $arr['presence'];
                 break;
             case isset($arr['message']):
                 $buffer['message'][] = $arr['message'];
                 break;
             case isset($arr['iq']):
                 XMPPGet::iq($arr['iq'], $this);
                 break;
             default:
                 $jaxl->log("Unrecognized payload received from jabber server...", 1);
                 break;
         }
     }
     if (isset($buffer['presence'])) {
         XMPPGet::presence($buffer['presence'], $this);
     }
     if (isset($buffer['message'])) {
         XMPPGet::message($buffer['message'], $this);
     }
     unset($buffer);
     JAXLPlugin::execute('jaxl_post_handler', $payload, $this);
 }