![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <BaseAPLCapabilityAgent.h>
Classes | |
struct | PresentationSessionFieldNames |
Protected Types | |
enum | DirectiveType { DirectiveType::RENDER_DOCUMENT, DirectiveType::SHOW_DOCUMENT, DirectiveType::EXECUTE_COMMAND, DirectiveType::DYNAMIC_TOKEN_DATA_SOURCE_UPDATE, DirectiveType::DYNAMIC_INDEX_DATA_SOURCE_UPDATE, DirectiveType::UNKNOWN } |
Concrete Implementation Facing Interfaces. More... | |
enum | MetricEvent { MetricEvent::RENDER_DOCUMENT } |
Enumeration of timer metrics events that could be emitted. More... | |
enum | MetricActivity { MetricActivity::ACTIVITY_RENDER_DOCUMENT, MetricActivity::ACTIVITY_RENDER_DOCUMENT_FAIL } |
Enumeration of timer metric activity names that could be emitted. More... | |
Protected Member Functions | |
virtual alexaClientSDK::avsCommon::avs::DirectiveHandlerConfiguration | getAPLDirectiveConfiguration () const =0 |
Template Methods to be implemented in Concrete Implementations. More... | |
virtual std::unordered_set< std::shared_ptr< alexaClientSDK::avsCommon::avs::CapabilityConfiguration > > | getAPLCapabilityConfigurations (const std::string &APLMaxVersion)=0 |
virtual DirectiveType | getDirectiveType (std::shared_ptr< DirectiveInfo > info)=0 |
virtual const std::string & | getConfigurationRootKey ()=0 |
virtual const std::string & | getMetricDataPointName (MetricEvent event)=0 |
virtual const std::string & | getMetricActivityName (MetricActivity activity)=0 |
virtual PresentationSessionFieldNames | getPresentationSessionFieldNames ()=0 |
virtual const bool | shouldPackPresentationSessionToAvsEvents ()=0 |
void | handleUnknownDirective (std::shared_ptr< DirectiveInfo > info) |
void | setHandlingCompleted (std::shared_ptr< DirectiveInfo > info) |
std::shared_ptr< alexaClientSDK::avsCommon::utils::threading::Executor > | getExecutor () |
![]() | |
CapabilityAgent (const std::string &nameSpace, std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender) | |
virtual std::shared_ptr< DirectiveInfo > | createDirectiveInfo (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result) |
void | removeDirective (const std::string &messageId) |
void | sendExceptionEncounteredAndReportFailed (std::shared_ptr< DirectiveInfo > info, const std::string &message, avsCommon::avs::ExceptionErrorType type=avsCommon::avs::ExceptionErrorType::INTERNAL_ERROR) |
const std::pair< std::string, std::string > | buildJsonEventString (const std::string &eventName, const std::string &dialogRequestIdString="", const std::string &payload="{}", const std::string &context="") const |
Additional Inherited Members | |
![]() | |
const std::string | m_namespace |
The namespace of the capability agent. More... | |
std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > | m_exceptionEncounteredSender |
Object to use to send exceptionEncountered messages. More... | |
This base class for an Alexa Presentation Language CapabilityAgent
that handles rendering APL documents.
Clients interested in APL events can subscribe themselves as an observer, and the clients will be notified via the Capability Agent Observer interface.
|
strongprotected |
Concrete Implementation Facing Interfaces.
Directive Types that could be received from AVS
|
strongprotected |
|
strongprotected |
alexaClientSDK::aplCapabilityCommon::BaseAPLCapabilityAgent::BaseAPLCapabilityAgent | ( | const std::string & | avsNamespace, |
std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > | exceptionSender, | ||
std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface > | metricRecorder, | ||
std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::MessageSenderInterface > | messageSender, | ||
std::shared_ptr< alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerInterface > | contextManager, | ||
const std::string & | APLMaxVersion, | ||
std::shared_ptr< alexaClientSDK::aplCapabilityCommonInterfaces::VisualStateProviderInterface > | visualStateProvider = nullptr |
||
) |
Constructor.
avsNamepace | The AVS namespace interface this CA operations within. |
exceptionSender | The object to use for sending AVS Exception messages. |
metricRecorder | The object to use for recording metrics. |
messageSender | The MessageSenderInterface that sends events to AVS. |
contextManager | The ContextManagerInterface used to generate system context for events. |
APLMaxVersion | The APL version supported. |
visualStateProvider | The VisualStateProviderInterface used to request visual context. |
|
virtualdefault |
Destructor.
|
overridevirtual |
Cancel an ongoing preHandleDirective()
or handleDirective()
operation for the AVSDirective
in . Once this has been called the CapabilityAgent
should not expect to receive further calls regarding this directive.
AVSDirectives
.info | The DirectiveInfo instance for the AVSDirective to process. |
Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
overridevirtual |
This function clears last received ExecuteCommands
directive (if it's still active) and mark them as failed.
token | The token. This should be passed in if we are clearing execute commands due to APL-specific trigger (eg. Finish command). This should be left empty if we are clearing due to global triggers (eg. back navigation) |
markAsFailed | Whether to mark the cleared commands as failed. |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
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.
Implements alexaClientSDK::avsCommon::utils::RequiresShutdown.
|
protectedpure virtual |
Get specific capability configuration for this APL Capability Agent
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
protectedpure virtual |
Template Methods to be implemented in Concrete Implementations.
Get specific directive handler configuration for this APL Capability Agent
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
overridevirtual |
Returns the configurations of the capability interfaces being implemented.
Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface.
|
overridevirtual |
Returns the configuration of the directive handler.
The configuration consists of multiple directive routing rules and their respective blocking policy. The directives will be matched from the most specific rule (with all fields defined) to the least specific rule (which only matches the directive endpointId).
avs::DirectiveHandlerConfiguration
of the handler. Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.
|
protectedpure virtual |
Get root key for the configuration values in the AVS json configuration
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
protectedpure virtual |
Get DirectiveType
from Directive header information
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
protected |
Get the executor used as the worker thread
Executor
shared_ptr
|
protectedpure virtual |
Given a Metric Activity, provide the metric data point name to publish.
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
protectedpure virtual |
Given a Metric Event, provide the metric data point name to publish.
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
protectedpure virtual |
In presentation session part of RenderDocument directives, there are some field names that differ slightly between CAs, the derived class may override this function to provide the field names that represent these fields in the directive.
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
|
overridevirtual |
Handle the action specified by the AVSDirective
in info
. The handling of subsequent directives with the same DialogRequestId
may be blocked until the DirectiveHandler
calls the setSucceeded()
method of the DirectiveHandlingResult
present in info
. If handling of this directive fails setFailed()
should be called to indicate a failure.
AVSDirectives
.info | The DirectiveInfo instance for the AVSDirective to process. |
Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
override |
|
protected |
This function handles any unknown directives received.
info | The DirectiveInfo containing the AVSDirective and the DirectiveHandlerResultInterface . |
|
virtual |
Intialize APL CA based on the configurations
|
overridevirtual |
This function notifies the APL CA that the active document has been replaced.
token | The new active document token |
session | The new presentation session |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
This is called by the ContextManager once the context is ready and available.
ContextRequester
should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders
.jsonContext | Context information.Context provided is of the format {"context"[{...}, {...}]} |
Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.
|
overridevirtual |
The contextManager calls this if it is unable to process a getContext
request successfully.
ContextRequester
should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders
.error | The reason why the getContext request failed. |
Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.
|
overridevirtual |
This function is called by the clients to provide the visual context to be passed to AVS.
requestToken | The token of the request for which this function is called. This should match the request token provided in VisualStateProviderInterface |
context | The visual state to be passed to AVS. The caller of this function is responsible to pass the payload as it defined in aplEventPayload::VisualContext |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
Notification that a directive has arrived. This notification gives the DirectiveHandler a chance to prepare for handling of an AVSDirective
. If an error occurs during the pre-Handling phase and that error should cancel the handling of subsequent AVSDirectives
with the same DialogRequestId
, the DirectiveHandler
should call the setFailed
method on the result
instance passed in to this call.
AVSDirectives
.info | The DirectiveInfo instance for the AVSDirective to process. |
Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
overridevirtual |
The function notifies the CA to initiate a proactive state report
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
Process result of ExecuteCommands directive.
token | request token |
event | the command result as defined in APLCommandExecutionEvent |
error | error message provided in case if result is false |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
Process result of RenderDocument directive.
token | document presentationToken. |
result | rendering result (true on rendered, false on exception). |
error | error message provided in case if result is false |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
A request to a StateProvider
to provide the state. The StateProvider
should perform minimum processing and return quickly, otherwise it will block the processing of updating the states of other StateProviders
. The ContextManager
specifies a token which it uses to track the getContext
request associated with this provideState
request. The stateProviderInterface
must use the same token when it updates its state via the setState
call.
: The setState method MUST be called from a different thread from where the provideState method is being called from.
stateProviderName | The name of the state provider. |
stateRequestToken | The token to use in the setState call. |
NamespaceAndName
is being deprecated. Use the CapabilityMessageIdentifier version instead. Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface.
|
overridevirtual |
Record the finish event for currently rendering document
timestamp | The timestamp at which the document was rendered |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
Send DataSourceFetchRequest
to AVS
payload | The DataSourceFetchRequest event payload. The caller of this function is responsible to pass the payload as it defined in aplEventPayload::DataSourceFetch . |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
Send RuntimeError
to AVS
payload | The RuntimeError event payload. The caller of this function is responsible to pass the payload as it defined in aplEventPayload::RuntimeError . |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
|
overridevirtual |
Send UserEvent
to AVS
payload | The UserEvent event payload. The caller of this function is responsible to pass the payload as it defined in aplEventPayload::UserEvent . |
Implements alexaClientSDK::aplCapabilityCommonInterfaces::APLCapabilityAgentInterface.
void alexaClientSDK::aplCapabilityCommon::BaseAPLCapabilityAgent::setExecutor | ( | const std::shared_ptr< alexaClientSDK::avsCommon::utils::threading::Executor > & | executor | ) |
Tests Facing interfaces.
Set the executor used as the worker thread
executor | The Executor to set |
|
protected |
Send the handling completed notification and clean up the resources.
info | The DirectiveInfo containing the AVSDirective and the DirectiveHandlerResultInterface . |
|
protectedpure virtual |
Whether AVS events should include presentationSession in their payload.
Implemented in alexaClientSDK::aplCapabilityCommon::test::APLCATest.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0