blob: 9620293bee6c3203e0f9dbf6a31d1504634493e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* Copyright (c) 2011-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <deque>
#include <memory>
#include <string>
#include <vector>
#include <boost/optional.hpp>
#include <boost/signals2.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Base/Error.h>
namespace Swift {
class Connection;
class Connector;
class ConnectionFactory;
class TimerFactory;
class DomainNameResolver;
class SWIFTEN_API ChainedConnector {
public:
ChainedConnector(const std::string& hostname, unsigned short port, const boost::optional<std::string>& serviceLookupPrefix, DomainNameResolver*, const std::vector<ConnectionFactory*>&, TimerFactory*);
~ChainedConnector();
void setTimeoutMilliseconds(int milliseconds);
void start();
void stop();
boost::signals2::signal<void (std::shared_ptr<Connection>, std::shared_ptr<Error>)> onConnectFinished;
private:
void finish(std::shared_ptr<Connection> connection, std::shared_ptr<Error>);
void tryNextConnectionFactory();
void handleConnectorFinished(std::shared_ptr<Connection>, std::shared_ptr<Error>);
private:
std::string hostname;
unsigned short port;
boost::optional<std::string> serviceLookupPrefix;
DomainNameResolver* resolver;
std::vector<ConnectionFactory*> connectionFactories;
TimerFactory* timerFactory;
int timeoutMilliseconds;
std::deque<ConnectionFactory*> connectionFactoryQueue;
std::shared_ptr<Connector> currentConnector;
std::shared_ptr<Error> lastError;
};
}
|