diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-10-05 10:46:31 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-10-05 10:46:31 +0200 |
commit | 45bd0449fb7f9fa8d09b2556a6cb2c8ff3c79d1e (patch) | |
tree | f587169a2a758054d9ab455bed0e8fe8114cfd80 | |
parent | 5371dd025a3c3b341c061d59f3c3d66cb07c0a2c (diff) |
sending initial ping before going online after login/resume to ensure that all presences and messages have been loaded
-rw-r--r-- | src/eu/siacs/conversations/xmpp/XmppConnection.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java index 76cfa603..07cd2b45 100644 --- a/src/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java @@ -311,7 +311,8 @@ public class XmppConnection implements Runnable { } catch (NumberFormatException e) { } - changeStatus(Account.STATUS_ONLINE); + sendInitialPing(); + } else if (nextTag.isStart("r")) { tagReader.readElement(nextTag); AckPacket ack = new AckPacket(this.stanzasReceived, smVersion); @@ -351,6 +352,21 @@ public class XmppConnection implements Runnable { } } } + + private void sendInitialPing() { + Log.d(Config.LOGTAG,account.getJid()+": sending intial ping"); + IqPacket iq = new IqPacket(IqPacket.TYPE_GET); + iq.setFrom(account.getFullJid()); + iq.addChild("ping", "urn:xmpp:ping"); + this.sendIqPacket(iq, new OnIqPacketReceived() { + + @Override + public void onIqPacketReceived(Account account, IqPacket packet) { + Log.d(Config.LOGTAG,account.getJid()+": online with resource "+account.getResource()); + changeStatus(Account.STATUS_ONLINE); + } + }); + } private Element processPacket(Tag currentTag, int packetType) throws XmlPullParserException, IOException { @@ -681,7 +697,7 @@ public class XmppConnection implements Runnable { if (bindListener != null) { bindListener.onBind(account); } - changeStatus(Account.STATUS_ONLINE); + sendInitialPing(); } else { disconnect(true); } |