我正在研究 ASmack。使用 asmack 获取聊天室用户列表是否可行? http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/muc.html 此列表未显示。请给我一些想法。
问问题
1331 次
3 回答
2
Which list?
You can only call getOccupants()
if you are an occupant of the MUC or, in other words, if have joined the MUC.
于 2012-05-05T10:26:44.333 回答
1
getOccupants()对我不起作用。所以你可以试试下面的代码:
try {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(xmppConn);
DiscoverItems discoItems = discoManager.discoverItems(roomJID);
Iterator<DiscoverItems.Item> occupants = discoItems.getItems();
} catch (XMPPException e) {
e.printStackTrace();
}
于 2014-01-22T18:18:28.627 回答
0
通过将参数作为 MultiUserChat 对象传递的简单跟随方法,我能够获取 XMPP 聊天室中可用的用户列表。
public static List<String> findMulitUser(MultiUserChat muc) {
List<String> listUser = new ArrayList<String>();
Iterator<String> it = muc.getOccupants();
// Traverse the chat room name
while (it.hasNext()) {
// Chat room members name
String name = StringUtils.parseResource(it.next());
System.out.println("Name Of Occupants------>" + name);
listUser.add(name);
}
return listUser;
}
于 2015-04-11T13:09:59.017 回答