From e21b855abf977fd0acdf6173db82f805e512f347 Mon Sep 17 00:00:00 2001 From: Nick Hudson Date: Mon, 14 Jul 2014 11:26:04 +0100 Subject: Apply a Connector timeout even if not using SRV lookups Corresponds to the Swiften change of the same name, d949d1638c Test-information: Unit tests pass. Verified that the new code works as expected in a test application that previously would never see timeouts. Change-Id: I95cc73a81e42d6ac00c79f74531e8dd6c67882f3 diff --git a/src/com/isode/stroke/network/Connector.java b/src/com/isode/stroke/network/Connector.java index 80caf0e..13a2bc3 100644 --- a/src/com/isode/stroke/network/Connector.java +++ b/src/com/isode/stroke/network/Connector.java @@ -9,7 +9,6 @@ package com.isode.stroke.network; import com.isode.stroke.network.DomainNameServiceQuery.Result; -import com.isode.stroke.signals.Signal1; import com.isode.stroke.signals.Signal2; import com.isode.stroke.signals.SignalConnection; import com.isode.stroke.signals.Slot; @@ -35,6 +34,15 @@ public class Connector { queriedAllServices = false; serviceQueryResults = new ArrayList(); + if (timeoutMilliseconds > 0) { + timer = timerFactory.createTimer(timeoutMilliseconds); + timer.onTick.connect(new Slot() { + public void call() { + handleTimeout(); + } + }); + timer.start(); + } if (serviceLookupPrefix != null) { serviceQuery = resolver.createServiceQuery(serviceLookupPrefix + hostname); serviceQuery.onResult.connect(new Slot1>() { @@ -42,15 +50,6 @@ public class Connector { handleServiceQueryResult(p1); } }); - if (timeoutMilliseconds > 0) { - timer = timerFactory.createTimer(timeoutMilliseconds); - timer.onTick.connect(new Slot() { - public void call() { - handleTimeout(); - } - }); - timer.start(); - } serviceQuery.run(); } else { -- cgit v0.10.2-6-g49f6