diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-05-24 13:15:31 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-05-24 18:16:22 (GMT) |
commit | 23387492f571e8e6c46c6fa6196bf496249c9853 (patch) | |
tree | 2ad95f6072367496383195f83a12a5be8fa2da40 /Swiften/Network/Connector.h | |
parent | 4b5d81c77aa37b9d4ce49f19aa4ef71fa482313b (diff) | |
download | swift-contrib-23387492f571e8e6c46c6fa6196bf496249c9853.zip swift-contrib-23387492f571e8e6c46c6fa6196bf496249c9853.tar.bz2 |
Make connector shared to avoid a crash on login.
Resolves: #346
Diffstat (limited to 'Swiften/Network/Connector.h')
-rw-r--r-- | Swiften/Network/Connector.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h index 39d63df..d283f2d 100644 --- a/Swiften/Network/Connector.h +++ b/Swiften/Network/Connector.h @@ -23,9 +23,13 @@ namespace Swift { class ConnectionFactory; class TimerFactory; - class Connector : public boost::bsignals::trackable { + class Connector : public boost::bsignals::trackable, public boost::enable_shared_from_this<Connector> { public: - Connector(const String& hostname, DomainNameResolver*, ConnectionFactory*, TimerFactory*); + typedef boost::shared_ptr<Connector> ref; + + static Connector::ref create(const String& hostname, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { + return Connector::ref(new Connector(hostname, resolver, connectionFactory, timerFactory)); + } void setTimeoutMilliseconds(int milliseconds); void start(); @@ -33,6 +37,8 @@ namespace Swift { boost::signal<void (boost::shared_ptr<Connection>)> onConnectFinished; private: + Connector(const String& hostname, DomainNameResolver*, ConnectionFactory*, TimerFactory*); + void handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result); void handleAddressQueryResult(const std::vector<HostAddress>& address, boost::optional<DomainNameResolveError> error); void queryAddress(const String& hostname); @@ -45,6 +51,7 @@ namespace Swift { void finish(boost::shared_ptr<Connection>); void handleTimeout(); + private: String hostname; DomainNameResolver* resolver; |