sending initial ping before going online after login/resume to ensure that all presences and messages have been loaded

This commit is contained in:
iNPUTmice 2014-10-05 10:46:31 +02:00
parent 5371dd025a
commit 45bd0449fb

View File

@ -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);
}