client-cpp  0.7.0
KaaClient.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 CyberVision, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef KAACLIENT_HPP_
18 #define KAACLIENT_HPP_
19 
20 #include "kaa/IKaaClient.hpp"
21 
22 #include "kaa/ClientStatus.hpp"
26 #include "kaa/event/gen/EventFamilyFactory.hpp"
31 #include "kaa/ClientStatus.hpp"
40 #include "kaa/log/LogCollector.hpp"
41 
42 namespace kaa {
43 
44 typedef std::shared_ptr<IBootstrapManager> IBootstrapManagerPtr;
45 
46 typedef enum KaaOption
47 {
53 } KaaOption;
54 
55 class KaaClient : public IKaaClient {
56 public:
57  KaaClient();
58  virtual ~KaaClient() { }
59 
60  void init(int options = KAA_DEFAULT_OPTIONS);
61  void start();
62  void stop();
63  void pause();
64  void resume();
65 
66  virtual void updateProfile();
68  virtual const KeyPair& getClientKeyPair();
69  virtual void setEndpointAccessToken(const std::string& token);
70  virtual std::string refreshEndpointAccessToken();
71  virtual std::string getEndpointAccessToken();
74  virtual EventFamilyFactory& getEventFamilyFactory();
75 
76  virtual void addLogRecord(const KaaUserLogRecord& record);
77  virtual void setLogStorage(ILogStoragePtr storage);
78  virtual void setLogUploadStrategy(ILogUploadStrategyPtr strategy);
79  virtual void setProfileContainer(IProfileContainerPtr container);
82  virtual Topics getTopics();
83  virtual void addNotificationListener(INotificationListener& listener);
84  virtual void addNotificationListener(const std::string& topidId,
85  INotificationListener& listener);
86  virtual void removeNotificationListener(INotificationListener& listener);
87  virtual void removeNotificationListener(const std::string& topidId,
88  INotificationListener& listener);
89  virtual void subscribeToTopic(const std::string& id, bool forceSync);
90  virtual void subscribeToTopics(const std::list<std::string>& idList, bool forceSync);
91  virtual void unsubscribeFromTopic(const std::string& id, bool forceSync);
92  virtual void unsubscribeFromTopics(const std::list<std::string>& idList, bool forceSync);
93  virtual void syncTopicSubscriptions();
94  virtual void addConfigurationListener(IConfigurationReceiver &receiver);
96  virtual const KaaRootConfiguration& getConfiguration();
98  virtual void attachEndpoint(const std::string& endpointAccessToken
100  virtual void detachEndpoint(const std::string& endpointKeyHash
102  virtual void attachUser(const std::string& userExternalId, const std::string& userAccessToken
104  virtual void attachUser(const std::string& userExternalId, const std::string& userAccessToken
105  , const std::string& userVerifierToken
107  virtual void setAttachStatusListener(IAttachStatusListenerPtr listener);
108  virtual bool isAttachedToUser();
109  virtual std::int32_t findEventListeners(const std::list<std::string>& eventFQNs
110  , IFetchEventListenersPtr listener);
111 
114 
115 private:
116  void initKaaConfiguration();
117  void initKaaTransport();
118  void initClientKeys();
119 
120  void setDefaultConfiguration();
121 
122 public:
126 private:
128  IBootstrapManagerPtr bootstrapManager_;
129  std::unique_ptr<ProfileManager> profileManager_;
130  std::unique_ptr<NotificationManager> notificationManager_;
131 
132  std::unique_ptr<KeyPair> clientKeys_;
133  std::string publicKeyHash_;
134 
135  std::unique_ptr<ConfigurationManager> configurationManager_;
136  std::unique_ptr<ConfigurationProcessor> configurationProcessor_;
137  std::unique_ptr<ConfigurationPersistenceManager> configurationPersistenceManager_;
138  std::unique_ptr<EventManager> eventManager_;
139  std::unique_ptr<EventFamilyFactory> eventFamilyFactory_;
140  std::unique_ptr<EndpointRegistrationManager> registrationManager_;
141  std::unique_ptr<LogCollector> logCollector_;
142  std::unique_ptr<IKaaChannelManager> channelManager_;
143  std::unique_ptr<SyncDataProcessor> syncProcessor_;
144 
145  std::unique_ptr<DefaultBootstrapChannel> bootstrapChannel_;
146  std::unique_ptr<DefaultOperationTcpChannel> opsTcpChannel_;
147  std::unique_ptr<DefaultOperationHttpChannel> opsHttpChannel_;
148  std::unique_ptr<DefaultOperationLongPollChannel> opsLongPollChannel_;
149 
150  int options_;
151 };
152 
153 }
154 
155 
156 
157 #endif /* KAACLIENT_HPP_ */
virtual IKaaDataDemultiplexer & getBootstrapDemultiplexer()
Retrieves Kaa bootstrap data demultiplexer.
The listener which receives updates on available topics.
virtual IKaaChannelManager & getChannelManager()
Retrieves the Channel Manager.
virtual void setLogStorage(ILogStoragePtr storage)
Sets the new log storage.
void init(int options=KAA_DEFAULT_OPTIONS)
virtual ~KaaClient()
Definition: KaaClient.hpp:58
virtual IKaaDataDemultiplexer & getOperationDemultiplexer()
Retrieves Kaa operations data demultiplexer.
virtual void subscribeToTopic(const std::string &id, bool forceSync)
Subscribes to the specified optional topic to receive notifications on that topic.
virtual std::string getEndpointAccessToken()
Retrieve an access token for a current endpoint.
virtual void setProfileContainer(IProfileContainerPtr container)
virtual void addTopicListListener(INotificationTopicListListener &listener)
Adds the listener which receives updates on the list of available topics.
virtual IKaaDataMultiplexer & getBootstrapMultiplexer()
Retrieves Kaa bootstrap data multiplexer.
KaaOption
Definition: KaaClient.hpp:46
virtual void removeTopicListListener(INotificationTopicListListener &listener)
Removes listener which receives updates on the list of available topics.
virtual void removeNotificationListener(INotificationListener &listener)
Removes the listener which receives notifications on all available topics.
std::shared_ptr< IDetachEndpointCallback > IDetachEndpointCallbackPtr
virtual void unsubscribeFromTopics(const std::list< std::string > &idList, bool forceSync)
Unsubscribes from the specified list of optional topics to stop receiving notifications on those topi...
virtual void attachEndpoint(const std::string &endpointAccessToken, IAttachEndpointCallbackPtr listener=IAttachEndpointCallbackPtr{})
Attaches the specified endpoint to the user to which the current endpoint is attached.
std::shared_ptr< IBootstrapManager > IBootstrapManagerPtr
Definition: KaaClient.hpp:44
virtual void setConfigurationStorage(IConfigurationStoragePtr storage)
virtual std::string refreshEndpointAccessToken()
Generate new access token for a current endpoint.
virtual void setLogUploadStrategy(ILogUploadStrategyPtr strategy)
Sets the new log upload strategy.
virtual void setEndpointAccessToken(const std::string &token)
Set new access token for a current endpoint.
std::shared_ptr< IProfileContainer > IProfileContainerPtr
std::shared_ptr< ILogStorage > ILogStoragePtr
The listener which receives notifications on the specified topic.
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr
virtual void addConfigurationListener(IConfigurationReceiver &receiver)
virtual void attachUser(const std::string &userExternalId, const std::string &userAccessToken, IUserAttachCallbackPtr listener=IUserAttachCallbackPtr{})
Attaches the current endpoint to the specifier user. The user verification is carried out by the defa...
virtual void syncTopicSubscriptions()
Sends subscription request(s) to the Operations server.
virtual void subscribeToTopics(const std::list< std::string > &idList, bool forceSync)
Subscribes to the specified list of optional topics to receive notifications on those topics...
virtual Topics getTopics()
Retrieves the list of available topics.
std::shared_ptr< IConfigurationStorage > IConfigurationStoragePtr
std::shared_ptr< IAttachStatusListener > IAttachStatusListenerPtr
virtual void removeConfigurationListener(IConfigurationReceiver &receiver)
virtual void unsubscribeFromTopic(const std::string &id, bool forceSync)
Unsubscribes from the specified optional topic to stop receiving notifications on that topic...
virtual void setAttachStatusListener(IAttachStatusListenerPtr listener)
Sets listener to notify of the current endpoint is attached/detached by another one.
std::shared_ptr< IUserAttachCallback > IUserAttachCallbackPtr
static const int KAA_DEFAULT_OPTIONS
Definition: KaaClient.hpp:123
virtual void updateProfile()
virtual std::int32_t findEventListeners(const std::list< std::string > &eventFQNs, IFetchEventListenersPtr listener)
Submits an event listeners resolution request.
virtual void addNotificationListener(INotificationListener &listener)
Adds the listener which receives notifications on all available topics.
virtual void detachEndpoint(const std::string &endpointKeyHash, IDetachEndpointCallbackPtr listener=IDetachEndpointCallbackPtr{})
Detaches the specified endpoint from the user to which the current endpoint is attached.
virtual void addLogRecord(const KaaUserLogRecord &record)
Adds a new log record to the log storage.
virtual IKaaDataMultiplexer & getOperationMultiplexer()
Retrieves Kaa operations data multiplexer.
std::shared_ptr< IFetchEventListeners > IFetchEventListenersPtr
std::shared_ptr< ILogUploadStrategy > ILogUploadStrategyPtr
virtual const KaaRootConfiguration & getConfiguration()
virtual const KeyPair & getClientKeyPair()
Retrieves the client's public and private key.
std::shared_ptr< IAttachEndpointCallback > IAttachEndpointCallbackPtr
virtual EventFamilyFactory & getEventFamilyFactory()
virtual bool isAttachedToUser()
Checks if the current endpoint is already attached to some user.