client-cpp  0.6.1
NotificationTransport.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 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 DEFAULTNOTIFICATIONTRANSPORT_HPP_
18 #define DEFAULTNOTIFICATIONTRANSPORT_HPP_
19 
20 #include "kaa/KaaDefaults.hpp"
21 
22 #ifdef KAA_USE_NOTIFICATIONS
23 
24 #include <map>
25 #include <set>
26 #include <string>
27 
33 
34 namespace kaa {
35 
36 class IKaaChannelManager;
37 
38 class NotificationTransport: public AbstractKaaTransport<TransportType::NOTIFICATION>,
39  public INotificationTransport
40 {
41 public:
42  NotificationTransport(IKaaClientStateStoragePtr status, IKaaChannelManager& manager)
43  : AbstractKaaTransport(manager), notificationProcessor_(nullptr)
44  {
45  setClientState(status);
46  }
47 
48  virtual NotificationSyncRequestPtr createEmptyNotificationRequest();
49 
50  virtual NotificationSyncRequestPtr createNotificationRequest();
51 
52  virtual void onNotificationResponse(const NotificationSyncResponse& response);
53 
54  virtual void onSubscriptionChanged(const SubscriptionCommands& commands);
55 
56  virtual void setNotificationProcessor(INotificationProcessor* processor) {
57  if (processor != nullptr) {
58  notificationProcessor_ = processor;
59  }
60  }
61 
62  virtual void sync() {
63  syncByType(type_);
64  }
65 private:
66  Notifications getUnicastNotifications(const Notifications & notifications);
67  Notifications getMulticastNotifications(const Notifications & notifications);
68 
69 private:
70  INotificationProcessor* notificationProcessor_;
71 
72  std::set<std::string> acceptedUnicastNotificationIds_;
73  std::map<std::string, std::int32_t> notificationSubscriptions_;
74  SubscriptionCommands subscriptions_;
75 };
76 
77 } /* namespace kaa */
78 
79 #endif
80 
81 #endif /* DEFAULTNOTIFICATIONTRANSPORT_HPP_ */
std::shared_ptr< IKaaClientStateStorage > IKaaClientStateStoragePtr
std::list< SubscriptionCommand > SubscriptionCommands
std::shared_ptr< NotificationSyncRequest > NotificationSyncRequestPtr