16 #ifndef ALEXA_CLIENT_SDK_CAPABILITIESDELEGATE_INCLUDE_CAPABILITIESDELEGATE_CAPABILITIESDELEGATE_H_
17 #define ALEXA_CLIENT_SDK_CAPABILITIESDELEGATE_INCLUDE_CAPABILITIESDELEGATE_CAPABILITIESDELEGATE_H_
19 #include <unordered_map>
45 namespace capabilitiesDelegate {
53 std::unordered_map<std::string, std::string>
pending;
57 std::unordered_map<std::string, std::string>
inFlight;
70 ,
public std::enable_shared_from_this<CapabilitiesDelegate> {
84 const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
85 std::unique_ptr<storage::CapabilitiesDelegateStorageInterface> storage,
86 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager,
87 const std::shared_ptr<
90 const std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownNotifierInterface>& shutdownNotifier,
91 const std::shared_ptr<acsdkAlexaEventProcessedNotifierInterfaces::AlexaEventProcessedNotifierInterface>&
92 alexaEventProcessedNotifier);
103 static std::shared_ptr<CapabilitiesDelegate>
create(
104 const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
105 const std::shared_ptr<storage::CapabilitiesDelegateStorageInterface>& storage,
106 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager);
112 const std::vector<avsCommon::avs::CapabilityConfiguration>& capabilities)
override;
116 const std::vector<avsCommon::avs::CapabilityConfiguration>& capabilities)
override;
119 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateObserverInterface> observer)
override;
122 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateObserverInterface> observer)
override;
127 const std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface>& messageSender)
override;
148 const std::unordered_map<std::string, std::string>& addOrUpdateReportEndpoints,
149 const std::unordered_map<std::string, std::string>& deleteReportEndpoints)
override;
182 const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
183 const std::shared_ptr<storage::CapabilitiesDelegateStorageInterface>& storage,
184 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager);
200 std::string getAuthToken();
212 void setCapabilitiesState(
215 const std::vector<avsCommon::sdkInterfaces::endpoints::EndpointIdentifier>& addOrUpdateReportEndpoints,
216 const std::vector<avsCommon::sdkInterfaces::endpoints::EndpointIdentifier>& deleteReportEndpoints);
227 bool updateEndpointConfigInStorage(
228 const std::unordered_map<std::string, std::string>& addOrUpdateReportEndpoints,
229 const std::unordered_map<std::string, std::string>& deleteReportEndpoints);
235 void resetCurrentDiscoveryEventSender();
241 void resetDiscoveryEventSender(
const std::shared_ptr<DiscoveryEventSenderInterface>& sender);
246 void executeSendPendingEndpoints();
251 bool isShuttingDown();
260 void addStaleEndpointsToPendingDeleteLocked(std::unordered_map<std::string, std::string>* storedEndpointConfig);
269 void filterUnchangedPendingAddOrUpdateEndpointsLocked(
270 std::unordered_map<std::string, std::string>* storedEndpointConfig);
276 void moveInFlightEndpointsToPendingLocked();
281 void moveInFlightEndpointsToPending();
286 void moveInFlightEndpointsToRegisteredEndpoints();
289 std::mutex m_observerMutex;
292 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateObserverInterface>>
293 m_capabilitiesObservers;
302 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> m_authDelegate;
305 std::shared_ptr<storage::CapabilitiesDelegateStorageInterface> m_capabilitiesDelegateStorage;
308 std::mutex m_isConnectedMutex;
315 std::mutex m_endpointsMutex;
324 std::unordered_map<std::string, std::string> m_endpoints;
327 std::mutex m_currentDiscoveryEventSenderMutex;
330 std::shared_ptr<DiscoveryEventSenderInterface> m_currentDiscoveryEventSender;
333 std::mutex m_messageSenderMutex;
336 std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> m_messageSender;
339 std::mutex m_isShuttingDownMutex;
342 bool m_isShuttingDown;
356 #endif // ALEXA_CLIENT_SDK_CAPABILITIESDELEGATE_INCLUDE_CAPABILITIESDELEGATE_CAPABILITIESDELEGATE_H_