AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <CapabilityAgent.h>
Classes | |
class | DirectiveInfo |
Protected Member Functions | |
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) |
virtual void | preHandleDirective (std::shared_ptr< DirectiveInfo > info)=0 |
virtual void | handleDirective (std::shared_ptr< DirectiveInfo > info)=0 |
virtual void | cancelDirective (std::shared_ptr< DirectiveInfo > info)=0 |
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 |
Protected Attributes | |
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... | |
CapabilityAgent
implements methods which most capability agents will need, namely:
DirectiveHandlerInterface
, AVSDirective
and DirectiveResultInterface
. Derived capability agents may extend this class. They may have to implement the following interfaces: ChannelObserverInterface:
To use the Activity Focus Manager Library, StateProviderInterface:
To provide state to the ContextManager
. ContextRequesterInterface:
To request context from the ContextManager
, as necessary.
|
virtualdefault |
Destructor.
|
protected |
Constructor for a Capability Agent.
nameSpace | The namespace of the capability agent. |
exceptionEncounteredSender | Object to use to send ExceptionEncountered messages. |
|
protected |
Builds a JSON event string which includes the header, the payload
and an optional context
. The header includes the namespace, name, message Id and an optional dialogRequestId
. The message Id required for the header is a random string that is generated and added to the header.
eventName | The name of the event to be include in the header. |
dialogRequestIdString | The value associated with the "dialogRequestId" key. |
payload | The payload value associated with the "payload" key. |
context | Optional context to be sent with the event message. |
|
finaloverridevirtual |
Cancel an ongoing preHandleDirective()
or handleDirective()
operation for the specified AVSDirective
. Once this has been called the DirectiveHandler
should not expect to receive further calls regarding this directive.
AVSDirectives
.messageId | The message ID of a directive previously passed to preHandleDirective(). |
Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.
|
protectedpure virtual |
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. |
Implemented in alexaClientSDK::capabilityAgents::aip::AudioInputProcessor, alexaClientSDK::avsCommon::test::MockCapabilityAgent, alexaClientSDK::acsdkAudioPlayer::AudioPlayer, alexaClientSDK::acsdkExternalMediaPlayer::ExternalMediaPlayer, alexaClientSDK::acsdkAlerts::AlertsCapabilityAgent, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::acsdkNotifications::NotificationsCapabilityAgent, alexaClientSDK::aplCapabilityCommon::BaseAPLCapabilityAgent, alexaClientSDK::capabilityAgents::mrm::MRMCapabilityAgent, alexaClientSDK::capabilityAgents::modeController::ModeControllerCapabilityAgent, alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent, alexaClientSDK::capabilityAgents::toggleController::ToggleControllerCapabilityAgent, and alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent.
|
protectedvirtual |
Create a DirectiveInfo instance with which to track the handling of an AVSDirective
.
directive | The AVSDirective to be processed. |
result | The object with which to communicate the outcome of processing the AVSDirective . |
directive
.
|
finaloverridevirtual |
Handle the action specified by the directive identified by messageId
. The handling of subsequent directives with the same DialogRequestId
may be blocked until the DirectiveHandler
calls the setSucceeded()
method of the DirectiveHandlingResult
instance passed in to the preHandleDirective()
call for the directive specified by messageId
. If handling of this directive fails such that subsequent directives with the same DialogRequestId
should be cancelled, this DirectiveHandler
should instead call setFailed() to indicate a failure.
ExceptionEncountered
message should be sent to AVS. AVSDirectives
.messageId | The message ID of a directive previously passed to preHandleDirective() . |
false
when messageId
is not recognized, else true
. Any errors related to handling of a valid messageId should be reported using DirectiveHandlerResultInterface::setFailed()
. Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.
|
protectedpure virtual |
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. |
Implemented in alexaClientSDK::capabilityAgents::aip::AudioInputProcessor, alexaClientSDK::avsCommon::test::MockCapabilityAgent, alexaClientSDK::acsdkAudioPlayer::AudioPlayer, alexaClientSDK::acsdkExternalMediaPlayer::ExternalMediaPlayer, alexaClientSDK::acsdkAlerts::AlertsCapabilityAgent, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::acsdkNotifications::NotificationsCapabilityAgent, alexaClientSDK::aplCapabilityCommon::BaseAPLCapabilityAgent, alexaClientSDK::capabilityAgents::mrm::MRMCapabilityAgent, alexaClientSDK::capabilityAgents::modeController::ModeControllerCapabilityAgent, alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent, alexaClientSDK::capabilityAgents::toggleController::ToggleControllerCapabilityAgent, and alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent.
|
overridevirtual |
Notification that this handler has been de-registered and will not receive any more calls.
Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.
Reimplemented in alexaClientSDK::capabilityAgents::aip::AudioInputProcessor, alexaClientSDK::acsdkAudioPlayer::AudioPlayer, alexaClientSDK::acsdkExternalMediaPlayer::ExternalMediaPlayer, alexaClientSDK::acsdkAlerts::AlertsCapabilityAgent, and alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer.
|
overridevirtual |
Used to notify the observer of the Channel of focus changes. Once called, the client should make a user observable change only and return immediately. Any additional work that needs to be done should be done on a separate thread or after returning. "User observable change" here refers to events that the end user of the product can visibly see or hear. For example, Alexa speech or music playing would be examples of user observable changes. Other work, such as database storing, logging, or communicating via network should be done on a different thread. Not doing so could result in delays for other clients trying to access the Channel.
newFocus | The new Focus of the channel. |
behavior | The mixingBehavior for the ChannelObserver to take as per the interrupt model |
Implements alexaClientSDK::avsCommon::sdkInterfaces::ChannelObserverInterface.
Reimplemented in alexaClientSDK::capabilityAgents::aip::AudioInputProcessor, alexaClientSDK::acsdkBluetooth::Bluetooth, alexaClientSDK::acsdkAudioPlayer::AudioPlayer, alexaClientSDK::acsdkAlerts::AlertsCapabilityAgent, and alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer.
|
finaloverride |
|
protectedpure virtual |
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. |
Implemented in alexaClientSDK::capabilityAgents::aip::AudioInputProcessor, alexaClientSDK::avsCommon::test::MockCapabilityAgent, alexaClientSDK::acsdkAudioPlayer::AudioPlayer, alexaClientSDK::acsdkExternalMediaPlayer::ExternalMediaPlayer, alexaClientSDK::acsdkAlerts::AlertsCapabilityAgent, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::acsdkNotifications::NotificationsCapabilityAgent, alexaClientSDK::aplCapabilityCommon::BaseAPLCapabilityAgent, alexaClientSDK::capabilityAgents::mrm::MRMCapabilityAgent, alexaClientSDK::capabilityAgents::modeController::ModeControllerCapabilityAgent, alexaClientSDK::capabilityAgents::rangeController::RangeControllerCapabilityAgent, alexaClientSDK::capabilityAgents::toggleController::ToggleControllerCapabilityAgent, and alexaClientSDK::capabilityAgents::powerController::PowerControllerCapabilityAgent.
|
protected |
This function releases resources associated with the AVSDirective
which is no longer in use by a CapabilityAgent
.
handleDirective()
and cancelDirective()
implementations after the outcome of handleDirective()
or cancelDirective()
has been reported.messageId | The message Id of the AVSDirective . |
|
protected |
Send ExceptionEncountered and report a failure to handle the AVSDirective
.
info | The AVSDirective that encountered the error and ancillary information. |
message | The error message to include in the ExceptionEncountered message. |
type | The type of Exception that was encountered. |
|
protected |
Object to use to send exceptionEncountered messages.
|
protected |
The namespace of the capability agent.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0