mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-09-28 02:39:33 +02:00
#getServiceNames will not fail if an items info cannot be discovered.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3012 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
65d5376606
commit
db8e2870f2
|
@ -204,14 +204,20 @@ public class MultiUserChat {
|
||||||
* @throws XMPPException if an error occured while trying to discover MUC services.
|
* @throws XMPPException if an error occured while trying to discover MUC services.
|
||||||
*/
|
*/
|
||||||
public static Collection getServiceNames(XMPPConnection connection) throws XMPPException {
|
public static Collection getServiceNames(XMPPConnection connection) throws XMPPException {
|
||||||
List answer = new ArrayList();
|
final List answer = new ArrayList();
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
||||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||||
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
|
try {
|
||||||
if (info.containsFeature("http://jabber.org/protocol/muc")) {
|
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
|
||||||
answer.add(item.getEntityID());
|
if (info.containsFeature("http://jabber.org/protocol/muc")) {
|
||||||
|
answer.add(item.getEntityID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
|
// Trouble finding info in some cases. This is a workaround for
|
||||||
|
// discovering info on remote servers.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
|
|
Loading…
Reference in a new issue