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:
parent
65d5376606
commit
db8e2870f2
1 changed files with 10 additions and 4 deletions
|
@ -204,14 +204,20 @@ public class MultiUserChat {
|
|||
* @throws XMPPException if an error occured while trying to discover MUC services.
|
||||
*/
|
||||
public static Collection getServiceNames(XMPPConnection connection) throws XMPPException {
|
||||
List answer = new ArrayList();
|
||||
final List answer = new ArrayList();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
|
||||
if (info.containsFeature("http://jabber.org/protocol/muc")) {
|
||||
answer.add(item.getEntityID());
|
||||
try {
|
||||
DiscoverInfo info = discoManager.discoverInfo(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;
|
||||
|
|
Loading…
Reference in a new issue