本文整理汇总了Java中org.jivesoftware.smackx.vcardtemp.packet.VCard.setTo方法的典型用法代码示例。如果您正苦于以下问题:Java VCard.setTo方法的具体用法?Java VCard.setTo怎么用?Java VCard.setTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.vcardtemp.packet.VCard
的用法示例。
在下文中一共展示了VCard.setTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveVCard
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入方法依赖的package包/类
/**
* Save this vCard for the user connected by 'connection'. XMPPConnection should be authenticated
* and not anonymous.
*
* @throws XMPPErrorException thrown if there was an issue setting the VCard in the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void saveVCard(VCard vcard) throws NoResponseException, XMPPErrorException, NotConnectedException {
// XEP-54 § 3.2 "A user may publish or update his or her vCard by sending an IQ of type "set" with no 'to' address…"
vcard.setTo(null);
vcard.setType(IQ.Type.set);
// Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't
// want to use the same stanza id again (although it wouldn't break if we did)
vcard.setStanzaId(StanzaIdUtil.newStanzaId());
connection().createPacketCollectorAndSend(vcard).nextResultOrThrow();
}
示例2: loadVCard
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入方法依赖的package包/类
/**
* Load VCard information for a given user.
*
* @throws XMPPErrorException
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public VCard loadVCard(String bareJid) throws NoResponseException, XMPPErrorException, NotConnectedException {
VCard vcardRequest = new VCard();
vcardRequest.setTo(bareJid);
VCard result = connection().createPacketCollectorAndSend(vcardRequest).nextResultOrThrow();
return result;
}