summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-04-11 18:28:11 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-04-18 19:11:42 (GMT)
commiteda3475756f88098de69d5bea05b328b53d7ec04 (patch)
treefb54c7df442d89bc104e21fc4a50fa7ac4a83975 /Swiften/Network/ChainedConnector.h
parente1a3e6495c2af6c5bea3e8aa81d83af4f7872e93 (diff)
downloadswift-contrib-eda3475756f88098de69d5bea05b328b53d7ec04.zip
swift-contrib-eda3475756f88098de69d5bea05b328b53d7ec04.tar.bz2
Added chained connector.
This connector will be useful for fallbacks in case of proxies.
Diffstat (limited to 'Swiften/Network/ChainedConnector.h')
-rw-r--r--Swiften/Network/ChainedConnector.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/Swiften/Network/ChainedConnector.h b/Swiften/Network/ChainedConnector.h
new file mode 100644
index 0000000..15b17f3
--- /dev/null
+++ b/Swiften/Network/ChainedConnector.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+#include <deque>
+#include <boost/shared_ptr.hpp>
+
+#include <Swiften/Base/boost_bsignals.h>
+
+namespace Swift {
+ class Connection;
+ class Connector;
+ class ConnectionFactory;
+ class TimerFactory;
+ class DomainNameResolver;
+
+ class ChainedConnector {
+ public:
+ ChainedConnector(const std::string& hostname, DomainNameResolver*, const std::vector<ConnectionFactory*>&, TimerFactory*);
+
+ void setTimeoutMilliseconds(int milliseconds);
+ void start();
+ void stop();
+
+ boost::signal<void (boost::shared_ptr<Connection>)> onConnectFinished;
+
+ private:
+ void finish(boost::shared_ptr<Connection> connection);
+ void tryNextConnectionFactory();
+ void handleConnectorFinished(boost::shared_ptr<Connection>);
+
+ private:
+ std::string hostname;
+ DomainNameResolver* resolver;
+ std::vector<ConnectionFactory*> connectionFactories;
+ TimerFactory* timerFactory;
+ int timeoutMilliseconds;
+ std::deque<ConnectionFactory*> connectionFactoryQueue;
+ boost::shared_ptr<Connector> currentConnector;
+ };
+};