Esempio n. 1
0
 /**
  * Handle iq event.
  *
  * @param XMLEvent $event
  * @retrun void
  */
 public function iq(XMLEvent $event)
 {
     if ($event->isEndTag()) {
         /* @var $element \DOMElement */
         $element = $event->getParameter(0);
         if ($this->getId() === $element->getAttribute('id')) {
             $this->blocking = false;
         }
     }
 }
 /**
  * Handle session event.
  *
  * @param XMLEvent $event
  * @return void
  */
 protected function respondeToFeatures(XMLEvent $event, $data)
 {
     if ($event->isEndTag()) {
         /* @var $element \DOMElement */
         $element = $event->getParameter(0);
         // bind element occured in <features>
         if ('features' === $element->parentNode->localName) {
             $this->blocking = true;
             $this->getConnection()->send(sprintf($data, $this->getId()));
         }
     }
 }
Esempio n. 3
0
 /**
  * Result received.
  *
  * @param \Fabiang\Xmpp\Event\XMLEvent $event
  * @return void
  */
 public function result(XMLEvent $event)
 {
     if ($event->isEndTag()) {
         $users = array();
         /* @var $element \DOMElement */
         $element = $event->getParameter(0);
         $items = $element->getElementsByTagName('item');
         /* @var $item \DOMElement */
         foreach ($items as $item) {
             $user = clone $this->getUserObject();
             $user->setName($item->getAttribute('name'))->setJid($item->getAttribute('jid'))->setSubscription($item->getAttribute('subscription'));
             $groups = $item->getElementsByTagName('group');
             foreach ($groups as $group) {
                 $user->addGroup($group->nodeValue);
             }
             $users[] = $user;
         }
         $this->getOptions()->setUsers($users);
         $this->blocking = false;
     }
 }
Esempio n. 4
0
 /**
  * Challenge string received.
  *
  * @param XMLEvent $event XML event
  * @return void
  */
 public function challenge(XMLEvent $event)
 {
     if ($event->isEndTag()) {
         list($element) = $event->getParameters();
         $challenge = XML::base64Decode($element->nodeValue);
         $values = $this->parseCallenge($challenge);
         if (isset($values['nonce'])) {
             $send = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $this->response($values) . '</response>';
         } elseif (isset($values['rspauth'])) {
             $send = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>';
         } else {
             throw new AuthenticationErrorException("Error when receiving challenge: \"{$challenge}\"");
         }
         $this->getConnection()->send($send);
     }
 }