if (useCache && featureCache.containsKey(targetUri) && identityCache.containsKey(targetUri)) {
handler.onDiscoveryInfoResult(featureCache.get(targetUri), identityCache.get(targetUri));
return;
}
final IQ iq = new IQ(IQ.Type.get);
iq.setTo(targetUri);
iq.addQuery(XmppNamespaces.DISCO_INFO);
session.sendIQ("disco", iq, new IQCallback() {
@Override
public void onIQSuccess(final IQ iq) {
final ImmutableSet<Feature> features = parseFeatures(iq.getQuery(XmppNamespaces.DISCO_INFO));
final ImmutableSet<Identity> identities = parseIdentities(iq.getQuery(XmppNamespaces.DISCO_INFO));
featureCache.put(targetUri, features);
identityCache.put(targetUri, identities);
handler.onDiscoveryInfoResult(features, identities);
}
@Override
public void onIQFailure(final IQ iq) {
featureCache.remove(targetUri);
identityCache.remove(targetUri);
handler.onDiscoveryInfoError(iq.getExtension("error", XmppNamespaces.DISCO_INFO));
}
});
}