1.我读过https://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions /filetransfer.html 本指南中的代码段代码,不需要资源部分
// Create the file transfer manager
FileTransferManager manager = new FileTransferManager(connection);
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer("romeo@montague.net");
// Send the file
transfer.sendFile(new File("shakespeare_complete_works.txt"), "You won't believe this!");
2.所以我读了火花源代码org.jivesoftware.spark.PresenceManager找到这个方法,所以文档很久没有更新;
/**
* Returns the fully qualified jid of a user.
*
* @param jid the users bare jid (ex. derek@jivesoftware.com)
* @return the fully qualified jid of a user (ex. derek@jivesoftware.com --> derek@jivesoftware.com/spark)
*/
public static String getFullyQualifiedJID(String jid) {
System.out.println("getFullyQualifiedJID : " + jid);
final Roster roster = SparkManager.getConnection().getRoster();
Presence presence = roster.getPresence(jid);
System.out.println("getFullyQualifiedJID : " + presence.getFrom());
return presence.getFrom();
}
我发现这种方法对于asmack不起作用,所以google发现了这个 Smack's FileTransferManager.createOutgoingFileTransfer only accepts full JIDs. How can I determine the full JID of a user in Smack?
//来自我的项目的代码段代码 名册名册= connection.getRoster(); 列表presenceList = roster.getPresences(jid); Log.d(TAG," bareJid:" + jid); for(Presence presence:presenceList){ Log.d(TAG," fullJID:" + presence.getFrom()); }
为什么代码无法获取fullJID。 输出:
12-23 06:55:35.840:D / MChat(1805):bareJid:test @ tigereye-pc 12-23 06:55:35.840:D / MChat(1805):fullJID:test @ tigereye-pc
4.结果是一样的,所以如何获得fullJID 谢谢&此致
答案 0 :(得分:0)
需要完整的JID和客户端资源。
你可以这样做:
String fullJID = xmppConnection.getRoster().getPresence(JID).getFrom();
我的JID变量是没有资源的完整JID。
答案 1 :(得分:0)
您必须提供完整用户ID:user @ serveripaddress / Smack
例如: xyz@192.168.1.1/Smack