【问题标题】:Get Friends list from openfire Server从 openfire 服务器获取好友列表
【发布时间】:2015-07-29 16:49:18
【问题描述】:

如何在目标 C 中以编程方式从 openfire 服务器获取所有朋友,我正在使用 XMPP 聊天功能框架。

【问题讨论】:

    标签: xmpp chat objective-c-blocks openfire


    【解决方案1】:

    这是一个获取朋友的函数。

    在下面的函数中添加您的主机名。

    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)
    }
    

    您将在委托方法中获得列表。

    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 连接和不同的代表。

    https://stackoverflow.com/a/50149977/2781720

    【讨论】:

      【解决方案2】:

      在 iOS 中,您可以在 xmpp 中使用以下功能轻松获取群组成员/朋友

      - (void)xmppRoom:(XMPPRoom *)sender didFetchModeratorsList:(NSArray *)items
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-02-05
        • 1970-01-01
        • 1970-01-01
        • 2012-04-03
        • 2021-10-03
        • 2014-11-15
        • 2015-03-16
        • 1970-01-01
        相关资源
        最近更新 更多