From 4a2e222b34291c0657323ca8aa35f1f301139257 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 30 Jun 2017 08:45:16 +0200 Subject: [PATCH] deduplicate disco items before disco#info --- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index ebff04d0b..303171240 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -31,6 +31,7 @@ import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -1092,6 +1093,7 @@ public class XmppConnection implements Runnable { public void sendDiscoTimeout() { if (mWaitForDisco.compareAndSet(true, false)) { + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": finalizing bind after disco timeout"); finalizeBind(); } } @@ -1231,15 +1233,19 @@ public class XmppConnection implements Runnable { @Override public void onIqPacketReceived(final Account account, final IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT) { + HashSet items = new HashSet(); final List elements = packet.query().getChildren(); for (final Element element : elements) { if (element.getName().equals("item")) { final Jid jid = element.getAttributeAsJid("jid"); if (jid != null && !jid.equals(account.getServer())) { - sendServiceDiscoveryInfo(jid); + items.add(jid); } } } + for(Jid jid : items) { + sendServiceDiscoveryInfo(jid); + } } else { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server); }