client-cpp  0.8.1
BootstrapManager.hpp
Go to the documentation of this file.
1 
17 #ifndef BOOTSTRAPMANAGER_HPP_
18 #define BOOTSTRAPMANAGER_HPP_
19 
20 #include <vector>
21 
22 #include "kaa/KaaThread.hpp"
26 #include "kaa/utils/KaaTimer.hpp"
28 
29 namespace kaa {
30 
31 class BootstrapManager : public IBootstrapManager, public boost::noncopyable {
32 public:
33  BootstrapManager(IKaaClientContext &context) : bootstrapTransport_(nullptr), channelManager_(nullptr), context_(context), retryTimer_("BootstrapManager retryTimer") { }
35 
36  virtual void setFailoverStrategy(IFailoverStrategyPtr strategy);
37  virtual void receiveOperationsServerList();
38  virtual void useNextOperationsServer(const TransportProtocolId& protocolId);
39  virtual void useNextOperationsServerByAccessPointId(std::int32_t id);
40  virtual void setTransport(IBootstrapTransport* transport);
41  virtual void setChannelManager(IKaaChannelManager* manager);
42  virtual void onServerListUpdated(const std::vector<ProtocolMetaData>& operationsServers);
43 
44 private:
45  typedef std::vector<ITransportConnectionInfoPtr> OperationsServers;
46 
47  OperationsServers getOPSByAccessPointId(std::int32_t id);
48  void notifyChannelManangerAboutServer(const OperationsServers& servers);
49 
50 private:
51  std::map<TransportProtocolId, OperationsServers > operationServers_;
52  std::map<TransportProtocolId, OperationsServers::iterator > lastOperationsServers_;
53 
54  BootstrapTransport *bootstrapTransport_;
55  IKaaChannelManager *channelManager_;
56 
57  IKaaClientContext &context_;
58 
59  IFailoverStrategyPtr failoverStrategy_;
60 
61  std::unique_ptr<std::int32_t> serverToApply;
62 
63  KaaTimer<void ()> retryTimer_;
64 
65  KAA_R_MUTEX_MUTABLE_DECLARE(guard_);
66 };
67 
68 }
69 
70 
71 
72 #endif /* BOOTSTRAPMANAGER_HPP_ */
virtual void setTransport(IBootstrapTransport *transport)
std::shared_ptr< IFailoverStrategy > IFailoverStrategyPtr
virtual void setFailoverStrategy(IFailoverStrategyPtr strategy)
virtual void setChannelManager(IKaaChannelManager *manager)
virtual void useNextOperationsServer(const TransportProtocolId &protocolId)
BootstrapManager(IKaaClientContext &context)
virtual void useNextOperationsServerByAccessPointId(std::int32_t id)
virtual void onServerListUpdated(const std::vector< ProtocolMetaData > &operationsServers)
virtual void receiveOperationsServerList()