AlexaClientSDK  1.20.1
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate Class Reference

#include <CapabilitiesDelegate.h>

Inheritance diagram for alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate:
Collaboration graph
[legend]

Public Member Functions

void addDiscoveryEventSender (const std::shared_ptr< DiscoveryEventSenderInterface > &discoveryEventSender)
 
CapabilitiesDelegateInterface method overrides.
bool addOrUpdateEndpoint (const avsCommon::avs::AVSDiscoveryEndpointAttributes &endpointAttributes, const std::vector< avsCommon::avs::CapabilityConfiguration > &capabilities) override
 
bool deleteEndpoint (const avsCommon::avs::AVSDiscoveryEndpointAttributes &endpointAttributes, const std::vector< avsCommon::avs::CapabilityConfiguration > &capabilities) override
 
void addCapabilitiesObserver (std::shared_ptr< avsCommon::sdkInterfaces::CapabilitiesObserverInterface > observer) override
 
void removeCapabilitiesObserver (std::shared_ptr< avsCommon::sdkInterfaces::CapabilitiesObserverInterface > observer) override
 
void invalidateCapabilities () override
 
void setMessageSender (const std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > &messageSender) override
 
AlexaEventProcessedObserverInterface method overrides.
void onAlexaEventProcessedReceived (const std::string &eventCorrelationToken) override
 
RequiresShutdown Functions
void doShutdown () override
 
PostConnectOperationInterfaceProvider Functions.
std::shared_ptr< avsCommon::sdkInterfaces::PostConnectOperationInterfacecreatePostConnectOperation () override
 
DiscoveryObserverInterface methods
void onDiscoveryCompleted (const std::unordered_map< std::string, std::string > &addOrUpdateReportEndpoints, const std::unordered_map< std::string, std::string > &deleteReportEndpoints) override
 
void onDiscoveryFailure (avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status status) override
 
AVSGatewayManagerInterface methods
void onAVSGatewayChanged (const std::string &avsGateway) override
 
CustomerDataHandler Functions
void clearData () override
 
ConnectionStatusObserverInterface Functions
void onConnectionStatusChanged (const Status status, const ChangedReason reason) override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::CapabilitiesDelegateInterface
virtual ~CapabilitiesDelegateInterface ()=default
 
virtual bool addOrUpdateEndpoint (const avsCommon::avs::AVSDiscoveryEndpointAttributes &endpointAttributes, const std::vector< avsCommon::avs::CapabilityConfiguration > &capabilities)=0
 
virtual bool deleteEndpoint (const avsCommon::avs::AVSDiscoveryEndpointAttributes &endpointAttributes, const std::vector< avsCommon::avs::CapabilityConfiguration > &capabilities)=0
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AlexaEventProcessedObserverInterface
virtual ~AlexaEventProcessedObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayObserverInterface
virtual ~AVSGatewayObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
virtual ~ConnectionStatusObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
 RequiresShutdown (const std::string &name)
 
virtual ~RequiresShutdown ()
 Destructor. More...
 
const std::string & name () const
 
void shutdown ()
 
bool isShutdown () const
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::PostConnectOperationProviderInterface
virtual ~PostConnectOperationProviderInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::capabilitiesDelegate::DiscoveryStatusObserverInterface
virtual ~DiscoveryStatusObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::registrationManager::CustomerDataHandler
 CustomerDataHandler (std::shared_ptr< CustomerDataManager > customerDataManager)
 
virtual ~CustomerDataHandler ()
 

Static Public Member Functions

static std::shared_ptr< CapabilitiesDelegatecreate (const std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > &authDelegate, const std::shared_ptr< storage::CapabilitiesDelegateStorageInterface > &storage, const std::shared_ptr< registrationManager::CustomerDataManager > &customerDataManager)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
enum  Status { Status::DISCONNECTED, Status::PENDING, Status::CONNECTED }
 
enum  ChangedReason {
  ChangedReason::NONE, ChangedReason::SUCCESS, ChangedReason::UNRECOVERABLE_ERROR, ChangedReason::ACL_CLIENT_REQUEST,
  ChangedReason::ACL_DISABLED, ChangedReason::DNS_TIMEDOUT, ChangedReason::CONNECTION_TIMEDOUT, ChangedReason::CONNECTION_THROTTLED,
  ChangedReason::INVALID_AUTH, ChangedReason::PING_TIMEDOUT, ChangedReason::WRITE_TIMEDOUT, ChangedReason::READ_TIMEDOUT,
  ChangedReason::FAILURE_PROTOCOL_ERROR, ChangedReason::INTERNAL_ERROR, ChangedReason::SERVER_INTERNAL_ERROR, ChangedReason::SERVER_SIDE_DISCONNECT,
  ChangedReason::SERVER_ENDPOINT_CHANGED
}
 

Detailed Description

CapabilitiesDelegate provides an implementation of the CapabilitiesDelegateInterface. It allows clients to register capabilities implemented by agents and publish them so that Alexa is aware of the device's capabilities.

Member Function Documentation

◆ addCapabilitiesObserver()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::addCapabilitiesObserver ( std::shared_ptr< avsCommon::sdkInterfaces::CapabilitiesObserverInterface observer)
overridevirtual

Specify an object to observe changes to the state of this CapabilitiesDelegate. During the call to this setter the observers onCapabilitiesStateChange() method will be called back with the current capabilities state.

Parameters
observerThe object to observe the state of this CapabilitiesDelegate.

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilitiesDelegateInterface.

◆ addDiscoveryEventSender()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::addDiscoveryEventSender ( const std::shared_ptr< DiscoveryEventSenderInterface > &  discoveryEventSender)

Adds the event sender used to send Discovery events.

◆ addOrUpdateEndpoint()

bool alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::addOrUpdateEndpoint ( const avsCommon::avs::AVSDiscoveryEndpointAttributes endpointAttributes,
const std::vector< avsCommon::avs::CapabilityConfiguration > &  capabilities 
)
override

◆ clearData()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::clearData ( )
overridevirtual

Reset any internal state that may be associated with a particular user.

Warning
Object must succeed in deleting any customer data.
This method is called while CustomerDataManager is in a locked state. Do not call or wait for any CustomerDataManager operation.

Implements alexaClientSDK::registrationManager::CustomerDataHandler.

◆ create()

std::shared_ptr< CapabilitiesDelegate > alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::create ( const std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > &  authDelegate,
const std::shared_ptr< storage::CapabilitiesDelegateStorageInterface > &  storage,
const std::shared_ptr< registrationManager::CustomerDataManager > &  customerDataManager 
)
static

Create an CapabilitiesDelegate.

Parameters
authDelegateThe auth delegate instance needed for CapabilitiesDelegate.
storageThe storage instance needed for CapabilitiesDelegate.
customerDataManagerObject that will track the CustomerDataHandler.
Returns
If successful, returns a new CapabilitiesDelegate, otherwise nullptr.

◆ createPostConnectOperation()

std::shared_ptr< PostConnectOperationInterface > alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::createPostConnectOperation ( )
overridevirtual

Creates a post connect operation instance.

Returns
a new instance of the PostConnectOperationInterface.

We track the original pending endpoints in order to notify observers of their registration, even if CapabilitiesDelegate does not need to actually send the events since they are already registered with AVS.

The endpoints that need to be sent to AVS.

If any endpoints were in-flight at the time of creating a post-connect operation, move them back to pending to be re-filtered and sent as part of the post-connect operation.

If the database is empty, send any cached endpoints as part of this post-connect operation.

If the stored endpoint is pending deletion, do not include it in the addOrUpdateReport.

If the registered endpoint does not have a pending change, add the stored configuration to the addOrUpdateReport. Otherwise, prefer the pending change as it's more recent.

Move endpoints from pending to in-flight, since they will now be sent.

Sometimes pending add/update endpoints do not need to be sent to AVS as they are already stored and registered with AVS. In this case, we should still notify observers that registration succeeded even though no Discovery event was sent. This logic is not required for pending delete endpoints, since calls to CapabilitiesDelegate.deleteEndpoint fail when the endpoint is not already cached with CapabilitiesDelegate.

Implements alexaClientSDK::avsCommon::sdkInterfaces::PostConnectOperationProviderInterface.

◆ deleteEndpoint()

bool alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::deleteEndpoint ( const avsCommon::avs::AVSDiscoveryEndpointAttributes endpointAttributes,
const std::vector< avsCommon::avs::CapabilityConfiguration > &  capabilities 
)
override

◆ doShutdown()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::doShutdown ( )
overridevirtual

Prepares/enables this object to be deleted. This should be the last function called on this object prior to deleting (or resetting) its shared_ptr.

Warning
  • Attempting to call functions on this object after calling shutdown() can result in undefined behavior.
  • Neglecting to call shutdown() on this object can result in resource leaks or other undefined behavior.

Implements alexaClientSDK::avsCommon::utils::RequiresShutdown.

◆ invalidateCapabilities()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::invalidateCapabilities ( )
overridevirtual

Invalidates the capabilities reported to the AVS last. Capabilities information should be rebuilt and reported to the AVS during the next synchronization.

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilitiesDelegateInterface.

◆ onAlexaEventProcessedReceived()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::onAlexaEventProcessedReceived ( const std::string &  eventCorrelationToken)
overridevirtual

This function is called whenever an Alexa.EventProcessed directive is received.

Parameters
eventCorrelationTokenThe EventCorrelationToken string.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AlexaEventProcessedObserverInterface.

◆ onAVSGatewayChanged()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::onAVSGatewayChanged ( const std::string &  avsGateway)
overridevirtual

Observer method to be called when the AVS Gateway is changed.

Parameters
avsGatewayThe AVS Gateway the device should be connected to.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayObserverInterface.

◆ onConnectionStatusChanged()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::onConnectionStatusChanged ( const Status  status,
const ChangedReason  reason 
)
overridevirtual

Called when the AVS connection state changes.

Parameters
statusThe current connection status.
reasonThe reason the status change occurred.

If newly connected, send Discovery events for any endpoints that may have been added or deleted during the post-connect stage.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface.

◆ onDiscoveryCompleted()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::onDiscoveryCompleted ( const std::unordered_map< std::string, std::string > &  addOrUpdateReportEndpoints,
const std::unordered_map< std::string, std::string > &  deleteReportEndpoints 
)
overridevirtual

This method will be called when the discovery event has completed successfully.

Note
: This method will be called from PostConnectCapabilitiesPublisher 's execution thread and should return immediately.
: This method will be called by the PostConnectCapabilitiesPublisher to report the success state when ALL of the the discovery events are sent.
Parameters
addOrUpdateReportEndpointsThe map of addOrUpdateReport endpoints sent in the discovery events.
deleteReportEndpointsThe map of deleteReport endpoints sent in the discovery events.

Implements alexaClientSDK::capabilitiesDelegate::DiscoveryStatusObserverInterface.

◆ onDiscoveryFailure()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::onDiscoveryFailure ( avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status  status)
overridevirtual

This method will be called when the discovery event has failed.

Parameters
statusThe MessageRequestObserverInterface::Status indicating the HTTP error encountered.

Implements alexaClientSDK::capabilitiesDelegate::DiscoveryStatusObserverInterface.

◆ removeCapabilitiesObserver()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::removeCapabilitiesObserver ( std::shared_ptr< avsCommon::sdkInterfaces::CapabilitiesObserverInterface observer)
overridevirtual

Remove an observer.

Parameters
observerThe observer to remove.

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilitiesDelegateInterface.

◆ setMessageSender()

void alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate::setMessageSender ( const std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > &  messageSender)
overridevirtual

Set the message sender to use for sending Discovery events to AVS when connected.

Parameters
messageSenderThe message sender.

Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilitiesDelegateInterface.


The documentation for this class was generated from the following files:

AlexaClientSDK 1.20.1 - Copyright 2016-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0