从openfire服务器获取朋友列表 [英] Get Friends list from openfire Server
本文介绍了从openfire服务器获取朋友列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在目标C中以编程方式从openfire服务器中获取所有朋友,我正在使用XMPP
聊天功能框架.
How to get all friends programmatically from openfire server in objective C, I am using XMPP
Framework for chat Functionality.
推荐答案
此处是获取朋友的功能.
Here is a function to fetch friends.
在以下功能中添加您的主机名.
Add your host name in below function.
func getList() {
let query = try! XMLElement(xmlString: "<query xmlns='http://jabber.org/protocol/disco#items' node='all users'/>")
let iq = XMPPIQ(type: "get", to: XMPPJID(string: "Your Host Name"), elementID: xmppStream.generateUUID(), child: query)
iq?.addAttribute(withName: "id", stringValue: "get")
xmppStream.send(iq)
}
您将通过委托方法获得列表.
You will get the list in delegate method.
extension YourClassName: XMPPRosterDelegate {
func xmppRosterDidEndPopulating(_ sender: XMPPRoster!) {
if let jids = xmppRoster.xmppRosterStorage.jids(for: xmppStream) as? [XMPPJID] {
print("JIDS: \(String(describing: jids))")
for item in jids {
print(item.user)
}
}
}
}
您可以查看我的XMPP连接和不同代表的此链接.
You can have a look at my this link for XMPP Connection and different delegates.
https://stackoverflow.com/a/50149977/2781720
这篇关于从openfire服务器获取朋友列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文