fail old/invalid iq stanzas on bind

This commit is contained in:
Daniel Gultsch 2015-08-06 14:54:37 +02:00
parent 5c0853f302
commit 6694af8fca

View file

@ -34,6 +34,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -709,6 +710,7 @@ public class XmppConnection implements Runnable {
} catch (final InterruptedException ignored) { } catch (final InterruptedException ignored) {
} }
} }
clearIqCallbacks();
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET); final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind") iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind")
.addChild("resource").setContent(account.getResource()); .addChild("resource").setContent(account.getResource());
@ -739,6 +741,17 @@ public class XmppConnection implements Runnable {
}); });
} }
private void clearIqCallbacks() {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": clearing iq iq callbacks");
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR);
Iterator<Entry<String, Pair<IqPacket, OnIqPacketReceived>>> iterator = this.packetCallbacks.entrySet().iterator();
while(iterator.hasNext()) {
Entry<String, Pair<IqPacket, OnIqPacketReceived>> entry = iterator.next();
entry.getValue().second.onIqPacketReceived(account,failurePacket);
iterator.remove();
}
}
private void sendStartSession() { private void sendStartSession() {
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET); final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
startSession.addChild("session","urn:ietf:params:xml:ns:xmpp-session"); startSession.addChild("session","urn:ietf:params:xml:ns:xmpp-session");