1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 22:12:05 +01: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:
Derek DeMoro 2005-11-01 15:16:48 +00:00 committed by derek
parent 65d5376606
commit db8e2870f2

View file

@ -204,16 +204,22 @@ 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();
try {
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID()); DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) { if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID()); 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;
} }