don't time out disco request but just send bind request
This commit is contained in:
parent
ff1b23b4d9
commit
58d5d2a1be
|
@ -117,9 +117,7 @@ public class XmppConnection implements Runnable {
|
||||||
private long lastSessionStarted = 0;
|
private long lastSessionStarted = 0;
|
||||||
private long lastDiscoStarted = 0;
|
private long lastDiscoStarted = 0;
|
||||||
private AtomicInteger mPendingServiceDiscoveries = new AtomicInteger(0);
|
private AtomicInteger mPendingServiceDiscoveries = new AtomicInteger(0);
|
||||||
private AtomicBoolean mIsServiceItemsDiscoveryPending = new AtomicBoolean(true);
|
private AtomicBoolean mWaitForDisco = new AtomicBoolean(true);
|
||||||
private boolean mWaitForDisco = true;
|
|
||||||
private final ArrayList<String> mPendingServiceDiscoveriesIds = new ArrayList<>();
|
|
||||||
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<>();
|
||||||
|
@ -977,25 +975,8 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendDiscoTimeout() {
|
public void sendDiscoTimeout() {
|
||||||
final IqPacket failurePacket = new IqPacket(IqPacket.TYPE.ERROR); //don't use timeout
|
if (mWaitForDisco.compareAndSet(true, false)) {
|
||||||
final ArrayList<OnIqPacketReceived> callbacks = new ArrayList<>();
|
finalizeBind();
|
||||||
synchronized (this.mPendingServiceDiscoveriesIds) {
|
|
||||||
for(String id : mPendingServiceDiscoveriesIds) {
|
|
||||||
synchronized (this.packetCallbacks) {
|
|
||||||
Pair<IqPacket, OnIqPacketReceived> pair = this.packetCallbacks.remove(id);
|
|
||||||
if (pair != null) {
|
|
||||||
callbacks.add(pair.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.mPendingServiceDiscoveriesIds.clear();
|
|
||||||
}
|
|
||||||
if (callbacks.size() > 0) {
|
|
||||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": sending disco timeout");
|
|
||||||
resetStreamId(); //we don't want to live with this for ever
|
|
||||||
}
|
|
||||||
for(OnIqPacketReceived callback : callbacks) {
|
|
||||||
callback.onIqPacketReceived(account,failurePacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,8 +1018,7 @@ public class XmppConnection implements Runnable {
|
||||||
this.disco.clear();
|
this.disco.clear();
|
||||||
}
|
}
|
||||||
mPendingServiceDiscoveries.set(0);
|
mPendingServiceDiscoveries.set(0);
|
||||||
mIsServiceItemsDiscoveryPending.set(true);
|
mWaitForDisco.set(mServerIdentity != Identity.NIMBUZZ);
|
||||||
mWaitForDisco = mServerIdentity != Identity.NIMBUZZ;
|
|
||||||
lastDiscoStarted = SystemClock.elapsedRealtime();
|
lastDiscoStarted = SystemClock.elapsedRealtime();
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": starting service discovery");
|
||||||
mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
|
mXmppConnectionService.scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode());
|
||||||
|
@ -1057,7 +1037,8 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
sendServiceDiscoveryInfo(account.getJid().toBareJid());
|
sendServiceDiscoveryInfo(account.getJid().toBareJid());
|
||||||
sendServiceDiscoveryItems(account.getServer());
|
sendServiceDiscoveryItems(account.getServer());
|
||||||
if (!mWaitForDisco) {
|
|
||||||
|
if (!mWaitForDisco.get()) {
|
||||||
finalizeBind();
|
finalizeBind();
|
||||||
}
|
}
|
||||||
this.lastSessionStarted = SystemClock.elapsedRealtime();
|
this.lastSessionStarted = SystemClock.elapsedRealtime();
|
||||||
|
@ -1068,7 +1049,7 @@ public class XmppConnection implements Runnable {
|
||||||
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");
|
||||||
String id = this.sendIqPacket(iq, new OnIqPacketReceived() {
|
this.sendIqPacket(iq, new OnIqPacketReceived() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
|
@ -1109,16 +1090,12 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
|
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
|
||||||
if (mPendingServiceDiscoveries.decrementAndGet() == 0
|
if (mPendingServiceDiscoveries.decrementAndGet() == 0
|
||||||
&& !mIsServiceItemsDiscoveryPending.get()
|
&& mWaitForDisco.compareAndSet(true, false)) {
|
||||||
&& mWaitForDisco) {
|
|
||||||
finalizeBind();
|
finalizeBind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
synchronized (this.mPendingServiceDiscoveriesIds) {
|
|
||||||
this.mPendingServiceDiscoveriesIds.add(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finalizeBind() {
|
private void finalizeBind() {
|
||||||
|
@ -1143,10 +1120,11 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendServiceDiscoveryItems(final Jid server) {
|
private void sendServiceDiscoveryItems(final Jid server) {
|
||||||
|
mPendingServiceDiscoveries.incrementAndGet();
|
||||||
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
|
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
|
||||||
iq.setTo(server.toDomainJid());
|
iq.setTo(server.toDomainJid());
|
||||||
iq.query("http://jabber.org/protocol/disco#items");
|
iq.query("http://jabber.org/protocol/disco#items");
|
||||||
String id = this.sendIqPacket(iq, new OnIqPacketReceived() {
|
this.sendIqPacket(iq, new OnIqPacketReceived() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
public void onIqPacketReceived(final Account account, final IqPacket packet) {
|
||||||
|
@ -1164,16 +1142,13 @@ public class XmppConnection implements Runnable {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server);
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server);
|
||||||
}
|
}
|
||||||
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
|
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
|
||||||
mIsServiceItemsDiscoveryPending.set(false);
|
if (mPendingServiceDiscoveries.decrementAndGet() == 0
|
||||||
if (mPendingServiceDiscoveries.get() == 0 && mWaitForDisco) {
|
&& mWaitForDisco.compareAndSet(true, false)) {
|
||||||
finalizeBind();
|
finalizeBind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
synchronized (this.mPendingServiceDiscoveriesIds) {
|
|
||||||
this.mPendingServiceDiscoveriesIds.add(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendEnableCarbons() {
|
private void sendEnableCarbons() {
|
||||||
|
|
Loading…
Reference in New Issue