示例#1
0
 public function _onPacket($conn, $xml)
 {
     if (substr($xml, 1, 7) == 'stream:') {
         $packet = XmlBranch::fromXml($xml);
         switch ($packet->tag) {
             case "stream":
                 $this->_info = (object) $packet->attributes;
                 $this->onOpen->run($this, $this->_info);
                 break;
             case "error":
                 $this->onStreamError->run($this, $packet);
                 break;
             case "features":
                 $this->_features = Stanza::fromXml($xml);
                 $this->onFeatures->run($this, $this->_features);
                 break;
         }
     }
 }
示例#2
0
文件: Stanza.php 项目: vincebe/xmpp
 public static function fromXml($xml, XmppClient $client = null)
 {
     if (!$xml instanceof \SimpleXMLElement) {
         $xml = @simplexml_load_string(preg_replace('/(<\\/?)([a-z]*?)\\:/si', '$1', $xml));
     }
     $stanza = parent::fromXml($xml);
     $stanza->_xmpp = $client;
     $stanza->xml = $xml;
     return $stanza;
 }