예제 #1
0
 public function test_xmpp_stanza_nested()
 {
     $xml = new JAXLXml('message', array('to' => '1@a.z', 'from' => '2@b.c'));
     $xml->c('body')->attrs(array('xml:lang' => 'en'))->t('hello')->up()->c('thread')->t('1234')->up()->c('nested')->c('nest')->t('nest1')->up()->c('nest')->t('nest2')->up()->c('nest')->t('nest3')->up()->up()->c('c')->attrs(array('hash' => '84jsdmnskd'));
     $stanza = new XMPPStanza($xml);
     $this->assertEquals('<message to="1@a.z" from="2@b.c"><body xml:lang="en">hello</body><thread>1234</thread><nested>' . '<nest>nest1</nest><nest>nest2</nest><nest>nest3</nest></nested><c hash="84jsdmnskd"></c></message>', $stanza->to_string());
 }
 function test_xmpp_stanza_from_jaxl_xml()
 {
     // xml to stanza test
     $xml = new JAXLXml('message', NS_JABBER_CLIENT, array('to' => '*****@*****.**', 'from' => '4@r.p/q'));
     $stanza = new XMPPStanza($xml);
     $stanza->c('body')->t('hello world');
     echo $stanza->to . "\n";
     echo $stanza->to_string() . "\n";
 }
예제 #3
0
파일: roster.php 프로젝트: sylae/loungesim
 function ingest(\XMPPStanza $stanza)
 {
     global $config;
     $xml = '<?xml version="1.0"?>' . $stanza->to_string();
     $from = new \XMPPJid($stanza->from);
     $room = $from->bare;
     $nick = $from->resource;
     $type = \qp($xml)->attr('type');
     if ($room == $config['jaxl']['jid']) {
         return true;
     }
     // Initialize the room roster if it doesn't exist yet.
     if (!array_key_exists($room, $this->roster)) {
         $this->roster[$room] = array();
     }
     if ($type == 'error') {
         return true;
     }
     // Find the status codes.
     $item = \qp($xml)->find('item');
     global $codes;
     $codes = array();
     \qp($xml, 'status')->map(function ($index, $item) {
         global $codes;
         $c = (int) qp($item)->attr('code');
         if (!array_key_exists($c, $codes)) {
             $codes[$c] = 0;
         }
         $codes[(int) qp($item)->attr('code')]++;
     });
     if ($type == 'unavailable') {
         $this->eventPresenceUnavailable($room, $nick, $codes, $item);
     } else {
         $this->eventPresenceDefault($room, $nick, $item, $xml);
     }
     return true;
 }