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;
79 ,
public std::enable_shared_from_this<CapabilitiesDelegate> {
93 static std::shared_ptr<CapabilitiesDelegateInterface> createCapabilitiesDelegateInterface(
94 const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
95 std::unique_ptr<storage::CapabilitiesDelegateStorageInterface> storage,
96 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager,
97 const std::shared_ptr<
100 const std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownNotifierInterface>& shutdownNotifier,
101 const std::shared_ptr<acsdkAlexaEventProcessedNotifierInterfaces::AlexaEventProcessedNotifierInterface>&
102 alexaEventProcessedNotifier,
103 const std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>&
metricRecorder =
nullptr);
114 static std::shared_ptr<CapabilitiesDelegate> create(
115 const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
116 const std::shared_ptr<storage::CapabilitiesDelegateStorageInterface>& storage,
117 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager,
118 const std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>&
metricRecorder =
nullptr);
122 bool addOrUpdateEndpoint(
124 const std::vector<avsCommon::avs::CapabilityConfiguration>& capabilities)
override;
128 const std::vector<avsCommon::avs::CapabilityConfiguration>& capabilities)
override;
130 void addCapabilitiesObserver(
131 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateObserverInterface> observer)
override;
133 void removeCapabilitiesObserver(
134 std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateObserverInterface> observer)
override;
136 void invalidateCapabilities()
override;
138 void setMessageSender(
139 const std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface>& messageSender)
override;
144 void onAlexaEventProcessedReceived(
const std::string& eventCorrelationToken)
override;
149 void doShutdown()
override;
154 std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface> createPostConnectOperation()
override;
159 void onDiscoveryCompleted(
160 const std::unordered_map<std::string, std::string>& addOrUpdateReportEndpoints,
161 const std::unordered_map<std::string, std::string>& deleteReportEndpoints)
override;
167 void onAVSGatewayChanged(
const std::string& avsGateway)
override;
172 void clearData()
override;
183 void setDiscoveryEventSender(
const std::shared_ptr<DiscoveryEventSenderInterface>& discoveryEventSender);
194 const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
195 const std::shared_ptr<storage::CapabilitiesDelegateStorageInterface>& storage,
196 const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager,
197 const std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>& metricsRecorder);
225 void setCapabilitiesState(
228 const std::vector<avsCommon::sdkInterfaces::endpoints::EndpointIdentifier>& addOrUpdateReportEndpoints,
229 const std::vector<avsCommon::sdkInterfaces::endpoints::EndpointIdentifier>& deleteReportEndpoints);
240 bool updateEndpointConfigInStorage(
241 const std::unordered_map<std::string, std::string>& addOrUpdateReportEndpoints,
242 const std::unordered_map<std::string, std::string>& deleteReportEndpoints);
248 void resetCurrentDiscoveryEventSender();
254 void resetDiscoveryEventSender(
const std::shared_ptr<DiscoveryEventSenderInterface>& sender);
259 void executeSendPendingEndpoints();
264 bool isShuttingDown();
273 void addStaleEndpointsToPendingDeleteLocked(std::unordered_map<std::string, std::string>* storedEndpointConfig);
282 void filterUnchangedPendingAddOrUpdateEndpointsLocked(
283 std::unordered_map<std::string, std::string>* storedEndpointConfig);
289 void moveInFlightEndpointsToPendingLocked();
294 void moveInFlightEndpointsToPending();
299 void moveInFlightEndpointsToRegisteredEndpoints();
307 bool executeSendDiscoveryEvents(
308 const std::unordered_map<std::string, std::string>& addOrUpdateEndpointsToSend,
309 const std::unordered_map<std::string, std::string>& deleteEndpointsToSend);
319 std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
322 std::mutex m_observerMutex;
325 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::CapabilitiesDelegateObserverInterface>>
326 m_capabilitiesObservers;
335 std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> m_authDelegate;
338 std::shared_ptr<storage::CapabilitiesDelegateStorageInterface> m_capabilitiesDelegateStorage;
341 std::mutex m_isConnectedMutex;
348 std::mutex m_endpointsMutex;
357 std::unordered_map<std::string, std::string> m_endpoints;
364 m_endpointRegistrations;
367 std::mutex m_currentDiscoveryEventSenderMutex;
370 std::shared_ptr<DiscoveryEventSenderInterface> m_currentDiscoveryEventSender;
373 std::mutex m_messageSenderMutex;
376 std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> m_messageSender;
379 std::mutex m_isShuttingDownMutex;
382 bool m_isShuttingDown;
396 #endif // ALEXA_CLIENT_SDK_CAPABILITIESDELEGATE_INCLUDE_CAPABILITIESDELEGATE_CAPABILITIESDELEGATE_H_ Definition: CapabilitiesDelegate.h:73
ChangedReason
Definition: ConnectionStatusObserverInterface.h:50
::std::string string
Definition: gtest-port.h:1097
Single-thread executor implementation.
Definition: Executor.h:45
Error
The enum Error encodes possible errors which may occur when changing state.
Definition: CapabilitiesDelegateObserverInterface.h:44
Definition: RequiresShutdown.h:32
Definition: CapabilitiesDelegateInterface.h:39
Definition: CapabilitiesDelegate.h:50
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
Definition: Optional.h:32
std::unordered_map< std::string, std::string > inFlight
Definition: CapabilitiesDelegate.h:57
Definition: AVSDiscoveryEndpointAttributes.h:41
State
The enum State describes the state of the CapabilitiesDelegate.
Definition: CapabilitiesDelegateObserverInterface.h:32
Definition: DiscoveryStatusObserverInterface.h:30
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::unordered_map< std::string, std::string > pending
Definition: CapabilitiesDelegate.h:53
Definition: PostConnectOperationProviderInterface.h:30
Definition: PostConnectOperationProviderRegistrarInterface.h:32
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
Status
Definition: MessageRequestObserverInterface.h:33
Definition: CustomerDataHandler.h:34
Status
Definition: ConnectionStatusObserverInterface.h:36