smack api在openfire服务器上获取所有公共房间 [英] smack api get all public rooms on openfire server

查看:183
本文介绍了smack api在openfire服务器上获取所有公共房间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XMPP smack api连接到Openfire服务器.我试图查询服务器以返回所有可用的公共房间,而无需事先知道这些房间的名称.这样做的目的是使我的客户可以显示所有可用公共房间的列表,并相应地加入它们. Smack扩展文档提供了一些返回示例来自服务器的房间信息,但是似乎都不适合我的需求.

I am using the XMPP smack api to connect to an Openfire server. I am trying to query the server to return all public rooms available without knowing this names of the rooms in advance. The goal of this is so that my client can display a list of all public rooms available and join them accordingly. The Smack Extensions Documentation provides several examples of returning room information from the server however none of them seem to fit my need.

一个示例要求您事先知道房间的名称,如果要显示客户否则不知道的可用房间,这是不好的.此示例的代码如下.

One example requires you to know the name of the room beforehand, which is no good if you want to display available rooms that the client otherwise has no knowledge of. The code for this example is as follows.

 // Discover information about the room roomName@conference.myserver
  RoomInfo info = MultiUserChat.getRoomInfo(conn, "roomName@conference.myserver");
  System.out.println("Number of occupants:" + info.getOccupantsCount());
  System.out.println("Room Subject:" + info.getSubject());

另一个示例使您可以查询所有联系人当前所在的房间.这似乎是获取房间名称的非常​​间接的方式,并且有可能将某些房间留在外面.由于XMPP是基于服务器的协议,而不是基于p2p的协议,因此这似乎不是实现此目的的最合乎逻辑的方式(尽管如果我错了,请更正我的想法).此代码示例如下

Another example allows you to query the rooms that all of your contacts are currently in. This seems to be a very indirect way of getting room names and has the potential to leave some of the rooms out. As XMPP is a server based protocol and not a p2p based protocol this does not seem like the most logical way of accomplishing this (although please correct me if I am wrong). This code example is as follows

 Iterator joinedRooms = MultiUserChat.getJoinedRooms(conn, "user3@host.org/Smack");

如果有人可以给我发送链接或提供有关如何完成此操作的示例,将不胜感激.

If someone could either please send me a link or provide an example of how to accomplish this it would be greatly appreciated.

推荐答案

您正在寻找的是 MultiUserChat.getHostedRooms().

这篇关于smack api在openfire服务器上获取所有公共房间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆