【问题标题】:Smack multi user chat list of online usersSmack 在线用户的多用户聊天列表
【发布时间】:2013-04-05 02:08:17
【问题描述】:

我正在使用帐户管理员从我的第三方服务器登录我的 openfire XMPP 服务器。

我需要在特定的多用户聊天中发现可用用户。 “可用”是指房间内所有在线用户。

我知道一种方法是连接到房间并监听用户的存在,但出于我的目的,我需要即时获取完整列表。

有可能吗?

【问题讨论】:

    标签: xmpp openfire smack multiuserchat


    【解决方案1】:

    是的,您可以为此使用 ServiceDiscovery。这是一个例子:

          // Obtain the ServiceDiscoveryManager associated with my Connection
          ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    
          // Get the items of a given XMPP entity
          // This example gets the items associated with online catalog service
          DiscoverItems discoItems = discoManager.discoverItems("plays.shakespeare.lit");
    
          // Get the discovered items of the queried XMPP entity
          Iterator it = discoItems.getItems();
          // Display the items of the remote XMPP entity
          while (it.hasNext()) {
              DiscoverItems.Item item = (DiscoverItems.Item) it.next();
              System.out.println(item.getEntityID());
              System.out.println(item.getNode());
              System.out.println(item.getName());
          }
    

    【讨论】:

    • 请记住,这只会完成一半:它会列出聊天室,它会列出每个聊天中的用户,但不会列出真实 i> 用户的 JID。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-26
    • 2011-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-07
    • 2012-01-14
    相关资源
    最近更新 更多