本文整理汇总了Java中org.jivesoftware.smack.packet.IQ.getTo方法的典型用法代码示例。如果您正苦于以下问题:Java IQ.getTo方法的具体用法?Java IQ.getTo怎么用?Java IQ.getTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.IQ
的用法示例。
在下文中一共展示了IQ.getTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IQReplyFilter
import org.jivesoftware.smack.packet.IQ; //导入方法依赖的package包/类
/**
* Filters for packets which are a valid reply to an IQ request.
* <p>
* Such a stanza(/packet) must have the same stanza(/packet) id and must be an IQ stanza(/packet) of type
* <code>RESULT</code> or <code>ERROR</code>. Moreover, it is necessary to check
* the <code>from</code> address to ignore forged replies.
* <p>
* We accept a <code>from</code> address if one of the following is true:
* <ul>
* <li>It matches the <code>to</code> address of the request.
* <li>The <code>to</code> address of the request was empty and the
* <code>from</code> address matches either the bare jid of the server or the
* (bare or full jid) of the client.
* <li>To <code>to</code> was our bare address and the <code>from</code> is empty.
* </ul>
* <p>
* For a discussion of the issues, see the thread "Spoofing of iq ids and
* misbehaving servers" from 2014-01 on the [email protected] mailing list
* and following discussion in February and March.
*
* @param iqPacket An IQ request. Filter for replies to this packet.
*/
public IQReplyFilter(IQ iqPacket, XMPPConnection conn) {
if (!iqPacket.isRequestIQ()) {
throw new IllegalArgumentException("IQ must be a request IQ, i.e. of type 'get' or 'set'.");
}
if (iqPacket.getTo() != null) {
to = iqPacket.getTo().toLowerCase(Locale.US);
} else {
to = null;
}
final String localJid = conn.getUser();
if (localJid == null) {
throw new IllegalArgumentException("Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once");
}
local = localJid.toLowerCase(Locale.US);
server = conn.getServiceName().toLowerCase(Locale.US);
packetId = iqPacket.getStanzaId();
StanzaFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT);
StanzaFilter idFilter = new StanzaIdFilter(iqPacket);
iqAndIdFilter = new AndFilter(iqFilter, idFilter);
fromFilter = new OrFilter();
fromFilter.addFilter(FromMatchesFilter.createFull(to));
if (to == null) {
fromFilter.addFilter(FromMatchesFilter.createBare(local));
fromFilter.addFilter(FromMatchesFilter.createFull(server));
}
else if (to.equals(XmppStringUtils.parseBareJid(local))) {
fromFilter.addFilter(FromMatchesFilter.createFull(null));
}
}