wait with status change to online after all disco queries have been made
This commit is contained in:
parent
11e58607c9
commit
5e151c7311
|
@ -116,6 +116,7 @@ public class XmppConnection implements Runnable {
|
||||||
private long lastPingSent = 0;
|
private long lastPingSent = 0;
|
||||||
private long lastConnect = 0;
|
private long lastConnect = 0;
|
||||||
private long lastSessionStarted = 0;
|
private long lastSessionStarted = 0;
|
||||||
|
private int mPendingServiceDiscoveries = 0;
|
||||||
private boolean mInteractive = false;
|
private boolean mInteractive = false;
|
||||||
private int attempt = 0;
|
private int attempt = 0;
|
||||||
private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
|
private final Hashtable<String, Pair<IqPacket, OnIqPacketReceived>> packetCallbacks = new Hashtable<>();
|
||||||
|
@ -926,18 +927,16 @@ public class XmppConnection implements Runnable {
|
||||||
synchronized (this.disco) {
|
synchronized (this.disco) {
|
||||||
this.disco.clear();
|
this.disco.clear();
|
||||||
}
|
}
|
||||||
|
mPendingServiceDiscoveries = 0;
|
||||||
|
sendServiceDiscoveryItems(account.getServer());
|
||||||
sendServiceDiscoveryInfo(account.getServer());
|
sendServiceDiscoveryInfo(account.getServer());
|
||||||
sendServiceDiscoveryInfo(account.getJid().toBareJid());
|
sendServiceDiscoveryInfo(account.getJid().toBareJid());
|
||||||
sendServiceDiscoveryItems(account.getServer());
|
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": online with resource " + account.getResource());
|
||||||
this.lastSessionStarted = SystemClock.elapsedRealtime();
|
this.lastSessionStarted = SystemClock.elapsedRealtime();
|
||||||
changeStatus(Account.State.ONLINE);
|
|
||||||
if (bindListener != null) {
|
|
||||||
bindListener.onBind(account);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendServiceDiscoveryInfo(final Jid jid) {
|
private void sendServiceDiscoveryInfo(final Jid jid) {
|
||||||
|
mPendingServiceDiscoveries++;
|
||||||
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
|
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
|
||||||
iq.setTo(jid);
|
iq.setTo(jid);
|
||||||
iq.query("http://jabber.org/protocol/disco#info");
|
iq.query("http://jabber.org/protocol/disco#info");
|
||||||
|
@ -988,6 +987,16 @@ public class XmppConnection implements Runnable {
|
||||||
} else {
|
} else {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco info for " + jid.toString());
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco info for " + jid.toString());
|
||||||
}
|
}
|
||||||
|
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
|
||||||
|
mPendingServiceDiscoveries--;
|
||||||
|
if (mPendingServiceDiscoveries <= 0) {
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": done with service discovery");
|
||||||
|
changeStatus(Account.State.ONLINE);
|
||||||
|
if (bindListener != null) {
|
||||||
|
bindListener.onBind(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue