简体   繁体   English

如何使用gloox lib获得活动房间列表?

[英]How can I get active rooms list with gloox lib?

I am writing an xmpp-based chat client using gloox 1.0. 我正在使用gloox 1.0编写基于xmpp的聊天客户端。 I can not find out the way to use gloox to get active rooms list on the server (rooms that other users have created). 我找不到使用gloox来获取服务器(其他用户创建的房间)上的活动房间列表的方法。 I use openfire as my local server. 我将openfire用作本地服务器。 How can I do that? 我怎样才能做到这一点?

You need to create a Disco object, and a custom class that inherits DiscoHandler . 您需要创建一个Disco对象,以及一个继承DiscoHandler的自定义类。

To query the list you call getDiscoItems(muc_server_jid, ...) . 要查询列表,请调用getDiscoItems(muc_server_jid,...) Your DiscoHandler should implement handleDiscoItems() , which receives a Disco::Items object, items . 您的DiscoHandler应该实现handleDiscoItems() ,它接收Disco :: Items对象items

You can use items.itemList() to get a std::list of pointers to Disco::Item objects. 您可以使用items.itemList()获得指向Disco :: Item对象的指针的std :: list For each Disco::Item you can call item.jid() and item.name() to get the address and (optional) name of the room. 对于每个Disco :: Item,您可以调用item.jid()和item.name()来获取房间的地址和(可选)名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM