diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-12-31 15:00:15 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-12-31 15:00:15 (GMT) |
commit | cb1cc3c0205295002f2cd760cbd801842b30096e (patch) | |
tree | d45c97ba64c75a69b99202b49fc0c230da1987ce /Swiften/Network/Connector.h | |
parent | a0a3f3a587295a5a0ef57af6ae34e8e97db60ef7 (diff) | |
download | swift-cb1cc3c0205295002f2cd760cbd801842b30096e.zip swift-cb1cc3c0205295002f2cd760cbd801842b30096e.tar.bz2 |
Put a timeout of 60s on connecting & resolving.
Resolves: #87.
Diffstat (limited to 'Swiften/Network/Connector.h')
-rw-r--r-- | Swiften/Network/Connector.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h index 6df3970..507f085 100644 --- a/Swiften/Network/Connector.h +++ b/Swiften/Network/Connector.h @@ -1,48 +1,54 @@ #pragma once #include <deque> #include <boost/signal.hpp> #include <boost/shared_ptr.hpp> #include "Swiften/Network/DomainNameServiceQuery.h" #include "Swiften/Network/Connection.h" +#include "Swiften/Network/Timer.h" #include "Swiften/Network/HostAddressPort.h" #include "Swiften/Base/String.h" #include "Swiften/Network/DomainNameResolveError.h" namespace Swift { class DomainNameAddressQuery; class DomainNameResolver; class ConnectionFactory; + class TimerFactory; class Connector : public boost::bsignals::trackable { public: - Connector(const String& hostname, DomainNameResolver*, ConnectionFactory*); + Connector(const String& hostname, DomainNameResolver*, ConnectionFactory*, TimerFactory*); void setTimeoutMilliseconds(int milliseconds); void start(); boost::signal<void (boost::shared_ptr<Connection>)> onConnectFinished; private: void handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result); void handleAddressQueryResult(const HostAddress& address, boost::optional<DomainNameResolveError> error); void queryAddress(const String& hostname); void tryNextHostname(); void tryConnect(const HostAddressPort& target); void handleConnectionConnectFinished(bool error); + void finish(boost::shared_ptr<Connection>); + void handleTimeout(); private: String hostname; DomainNameResolver* resolver; ConnectionFactory* connectionFactory; + TimerFactory* timerFactory; int timeoutMilliseconds; + boost::shared_ptr<Timer> timer; boost::shared_ptr<DomainNameServiceQuery> serviceQuery; std::deque<DomainNameServiceQuery::Result> serviceQueryResults; boost::shared_ptr<DomainNameAddressQuery> addressQuery; bool queriedAllHosts; boost::shared_ptr<Connection> currentConnection; }; }; |