コード例 #1
0
ファイル: Stanza.php プロジェクト: vincebe/xmpp
 public function _set_to($value)
 {
     if (!$value instanceof Jid) {
         $value = new Jid($value);
     }
     $this->_to = $value;
     $this['to'] = $value->__toString();
 }
コード例 #2
0
ファイル: Presence.php プロジェクト: vincebe/xmpp
 /**
  * Helper, gets jid from packet.
  *
  * @return Jid
  */
 public function _get_jid()
 {
     $jid = $this['from'];
     $item = $this->xpath('//user:item[@jid]', ['user' => 'http://jabber.org/protocol/muc#user']);
     if (!empty($item)) {
         $jid = $item[0]['jid'];
     }
     if (!isset($this->_jid) || $this->_jid->__toString() != $jid) {
         $this->_jid = new Jid($jid);
     }
     return $this->_jid;
 }
コード例 #3
0
ファイル: XmppClient.php プロジェクト: vincebe/xmpp
 /**
  * Gets user affiliation list.
  *
  * @param Jid      $room        Jid of room to query.
  * @param string   $affiliation Affiliation type.
  * @param callable $delegate    Delegate to run after proper packet came.
  *                              Delegate takes one argument (packet) of type SimpleXMLElement.
  *
  * @internal Plugins should use Room::affiliationList() instead of that.
  *
  * @throws \InvalidArgumentException
  */
 public function affiliationList(Jid $room, $affiliation, callable $delegate)
 {
     if (!in_array($affiliation, array('none', 'outcast', 'member', 'admin', 'owner'))) {
         throw new \InvalidArgumentException('affiliation');
     }
     $xml = new xmlBranch("iq");
     $id = uniqid('affiliate_');
     $xml->addAttribute("type", "get")->addAttribute('from', $this->jid->__toString())->addAttribute("to", $room->__toString())->addAttribute("id", $id);
     $xml->addChild(new xmlBranch("query"));
     $xml->query[0]->addAttribute("xmlns", "http://jabber.org/protocol/muc#admin");
     $xml->query[0]->addChild(new xmlBranch("item"));
     $xml->query[0]->item[0]->addAttribute("affiliation", $affiliation);
     $this->write($xml->asXml());
     $this->wait('iq', $id, $delegate);
 }
コード例 #4
0
ファイル: Roster.php プロジェクト: vincebe/xmpp
 /**
  * @param Jid $jid
  *
  * @return RosterItem|null
  */
 public function byJid(Jid $jid)
 {
     foreach ($this->contacts as $contact) {
         if ($contact->jid->bare() == $jid->bare()) {
             return $contact;
         }
     }
     return null;
 }
コード例 #5
0
ファイル: RosterItem.php プロジェクト: vincebe/xmpp
 public function _set_jid(Jid $jid = null)
 {
     $this['jid'] = $jid ? $jid->bare() : null;
 }