AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender Class Reference

#include <AlexaInterfaceMessageSender.h>

Inheritance diagram for alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender:
Collaboration graph
[legend]

Public Member Functions

 ~AlexaInterfaceMessageSender ()
 
ContextManagerObserverInterface methods
void onStateChanged (const avsCommon::avs::CapabilityTag &identifier, const avsCommon::avs::CapabilityState &state, const avsCommon::sdkInterfaces::AlexaStateChangeCauseType cause) override
 
ContextRequesterInterface methods
void onContextAvailable (const std::string &endpointId, const avsCommon::avs::AVSContext &endpointContext, avsCommon::sdkInterfaces::ContextRequestToken token) override
 
void onContextFailure (const avsCommon::sdkInterfaces::ContextRequestError error, avsCommon::sdkInterfaces::ContextRequestToken token) override
 
MessageRequestObserverInterface methods
void onSendCompleted (avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status status) override
 
void onExceptionReceived (const std::string &exceptionMessage) override
 
AlexaInterfaceMessageSenderInternalInterface methods
virtual bool sendStateReportEvent (const std::string &instance, const std::string &correlationToken, const avsCommon::avs::AVSMessageEndpoint &endpoint) override
 
virtual bool sendResponseEvent (const std::string &instance, const std::string &correlationToken, const avsCommon::avs::AVSMessageEndpoint &endpoint, const std::string &jsonPayload="{}") override
 
virtual bool sendResponseEvent (const std::string &instance, const std::string &correlationToken, const avsCommon::avs::AVSMessageEndpoint &endpoint, const std::string &responseNamespace, const std::string &responseName, const std::string &jsonPayload="{}") override
 
virtual bool sendErrorResponseEvent (const std::string &instance, const std::string &correlationToken, const avsCommon::avs::AVSMessageEndpoint &endpoint, const ErrorResponseType errorType, const std::string &errorMessage="") override
 
bool sendErrorResponseEvent (const std::string &instance, const std::string &correlationToken, const avsCommon::avs::AVSMessageEndpoint &endpoint, const std::string &responseNamespace, const std::string &jsonPayload="{}") override
 
virtual bool sendDeferredResponseEvent (const std::string &instance, const std::string &correlationToken, const int estimatedDeferralInSeconds=0) override
 
- Public Member Functions inherited from alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface
virtual ~AlexaInterfaceMessageSenderInternalInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface
virtual ~AlexaInterfaceMessageSenderInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerObserverInterface
virtual ~ContextManagerObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface
virtual ~ContextRequesterInterface ()=default
 
virtual void onContextAvailable (const std::string &jsonContext)
 
virtual void onContextFailure (const ContextRequestError error)
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::MessageRequestObserverInterface
virtual ~MessageRequestObserverInterface ()=default
 
virtual void onResponseStatusReceived (MessageRequestObserverInterface::Status status)
 
- 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
 

Static Public Member Functions

static std::shared_ptr< AlexaInterfaceMessageSendercreateAlexaInterfaceMessageSender (const std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > &contextManager, const std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > &messageSender, const std::shared_ptr< acsdkShutdownManagerInterfaces::ShutdownNotifierInterface > &shutdownNotifier)
 
static std::shared_ptr< AlexaInterfaceMessageSenderInternalInterfacecreateAlexaInterfaceMessageSenderInternalInterface (const std::shared_ptr< AlexaInterfaceMessageSender > &messageSender)
 
static std::shared_ptr< AlexaInterfaceMessageSendercreate (std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender)
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface
static ErrorResponseType alexaResponseTypeToErrorType (const avsCommon::avs::AlexaResponseType responseType)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface
enum  ErrorResponseType {
  ErrorResponseType::ALREADY_IN_OPERATION, ErrorResponseType::BRIDGE_UNREACHABLE, ErrorResponseType::ENDPOINT_BUSY, ErrorResponseType::ENDPOINT_LOW_POWER,
  ErrorResponseType::ENDPOINT_UNREACHABLE, ErrorResponseType::EXPIRED_AUTHORIZATION_CREDENTIAL, ErrorResponseType::FIRMWARE_OUT_OF_DATE, ErrorResponseType::HARDWARE_MALFUNCTION,
  ErrorResponseType::INSUFFICIENT_PERMISSIONS, ErrorResponseType::INTERNAL_ERROR, ErrorResponseType::INVALID_AUTHORIZATION_CREDENTIAL, ErrorResponseType::INVALID_DIRECTIVE,
  ErrorResponseType::INVALID_VALUE, ErrorResponseType::NO_SUCH_ENDPOINT, ErrorResponseType::NOT_CALIBRATED, ErrorResponseType::NOT_SUPPORTED_IN_CURRENT_MODE,
  ErrorResponseType::NOT_IN_OPERATION, ErrorResponseType::POWER_LEVEL_NOT_SUPPORTED, ErrorResponseType::RATE_LIMIT_EXCEEDED, ErrorResponseType::TEMPERATURE_VALUE_OUT_OF_RANGE,
  ErrorResponseType::VALUE_OUT_OF_RANGE
}
 The type of error when calling sendErrorResponseEvent(). More...
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::MessageRequestObserverInterface
enum  Status {
  Status::PENDING, Status::SUCCESS, Status::SUCCESS_ACCEPTED, Status::SUCCESS_NO_CONTENT,
  Status::NOT_CONNECTED, Status::NOT_SYNCHRONIZED, Status::TIMEDOUT, Status::PROTOCOL_ERROR,
  Status::INTERNAL_ERROR, Status::SERVER_INTERNAL_ERROR_V2, Status::REFUSED, Status::CANCELED,
  Status::THROTTLED, Status::INVALID_AUTH, Status::BAD_REQUEST, Status::SERVER_OTHER_ERROR
}
 

Detailed Description

Implementation of AlexaInterfaceMessageSenderInterface and AlexaInterfaceMessageSenderInternalInterface. This class implementes centralized messaging for any AlexaInterface capability that needs to send AlexaInterface events.

Constructor & Destructor Documentation

◆ ~AlexaInterfaceMessageSender()

alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::~AlexaInterfaceMessageSender ( )

Destructor.

Member Function Documentation

◆ create()

std::shared_ptr< AlexaInterfaceMessageSender > alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::create ( std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface contextManager,
std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface messageSender 
)
static

Factory method to create a AlexaInterfaceMessageSender.

Deprecated:
Use createAlexaInterfaceMessageSender.
Parameters
contextManagerInterface to access AVS state.
messageSenderInterface to send events to AVS.
Returns
A new instance of AlexaInterfaceMessageSender on success, nullptr otherwise.

◆ createAlexaInterfaceMessageSender()

std::shared_ptr< AlexaInterfaceMessageSender > alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::createAlexaInterfaceMessageSender ( const std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > &  contextManager,
const std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > &  messageSender,
const std::shared_ptr< acsdkShutdownManagerInterfaces::ShutdownNotifierInterface > &  shutdownNotifier 
)
static

Factory method to create a AlexaInterfaceMessageSender.

Parameters
contextManagerInterface to access AVS state.
connectionManagerInterface to send events to AVS.
shutdownNotifierInterface to notify of shutdown.
Returns
A new instance of AlexaInterfaceMessageSender on success, nullptr otherwise.

◆ createAlexaInterfaceMessageSenderInternalInterface()

std::shared_ptr< AlexaInterfaceMessageSenderInternalInterface > alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::createAlexaInterfaceMessageSenderInternalInterface ( const std::shared_ptr< AlexaInterfaceMessageSender > &  messageSender)
static

Factory method to forward an instance of AlexaInterfaceMessageSender to AlexaInterfaceMessageSenderInternalInterface.

Parameters
messageSenderThe instance to forward.
Returns
A forwarded instance of AlexaInterfaceMessageSenderInternalInterface.

◆ onContextAvailable()

void alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::onContextAvailable ( const std::string &  endpointId,
const avsCommon::avs::AVSContext endpointContext,
avsCommon::sdkInterfaces::ContextRequestToken  requestToken 
)
overridevirtual

This is called by the ContextManager once the context is ready and available.

Note
The ContextRequester should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders.
In future versions, this method will be made pure virtual.
Parameters
endpointIdThe ID used to identify the endpoint to which this context belong.
endpointContextThe state of all capabilities related to the given endpoint.
requestTokenToken used to identify a specific context request.

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.

◆ onContextFailure()

void alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::onContextFailure ( const avsCommon::sdkInterfaces::ContextRequestError  error,
avsCommon::sdkInterfaces::ContextRequestToken  token 
)
overridevirtual

The contextManager calls this if it is unable to process a getContext request successfully.

Note
The ContextRequester should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders.
In future versions, this method will be made pure virtual.
Parameters
errorThe reason why the getContext request failed.
requestTokenToken used to identify a specific context request.

Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.

◆ onExceptionReceived()

void alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::onExceptionReceived ( const std::string &  exceptionMessage)
overridevirtual

◆ onSendCompleted()

void alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::onSendCompleted ( avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status  status)
overridevirtual

◆ onStateChanged()

void alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::onStateChanged ( const avsCommon::avs::CapabilityTag identifier,
const avsCommon::avs::CapabilityState state,
const avsCommon::sdkInterfaces::AlexaStateChangeCauseType  cause 
)
overridevirtual

Notifies the observer that a change of state has been proactively reported.

Parameters
identifierIdentifies the source of the state change.
stateThe new state.
causeThe reason for the state change.

Implements alexaClientSDK::avsCommon::sdkInterfaces::ContextManagerObserverInterface.

◆ sendDeferredResponseEvent()

bool alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::sendDeferredResponseEvent ( const std::string &  instance,
const std::string &  correlationToken,
const int  estimatedDeferralInSeconds = 0 
)
overridevirtual

Send an Alexa.DeferredResponse event. The message is enqueued for sending and this method returns immediately (non-blocking).

Parameters
instanceThe instance ID of the responding capability.
correlationTokenThe correlation token from the directive to which we are responding.
estimatedDeferralInSecondsnumber of seconds until the response is expected.
Returns
true if the message was sent successfully, false otherwise.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface.

◆ sendErrorResponseEvent() [1/2]

bool alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::sendErrorResponseEvent ( const std::string &  instance,
const std::string &  correlationToken,
const avsCommon::avs::AVSMessageEndpoint endpoint,
const ErrorResponseType  errorType,
const std::string &  errorMessage = "" 
)
overridevirtual

Send an Alexa.ErrorResponse event. The message is enqueued for sending and this method returns immediately (non-blocking).

Parameters
instanceThe instance ID of the responding capability.
correlationTokenThe correlation token from the directive to which we are responding.
endpointThe AVSMessageEndpoint to identify the endpoint related to this event.
errorTypethe error type.
errorMessagea string containing the error message (optional).
Returns
true if the message was enqueued successfully, false otherwise.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface.

◆ sendErrorResponseEvent() [2/2]

bool alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::sendErrorResponseEvent ( const std::string &  instance,
const std::string &  correlationToken,
const avsCommon::avs::AVSMessageEndpoint endpoint,
const std::string &  responseNamespace,
const std::string &  jsonPayload = "{}" 
)
overridevirtual

Send an error response event for namespace and name. The message is enqueued for sending and this method returns immediately (non-blocking).

Parameters
instanceThe instance ID of the responding capability.
correlationTokenThe correlation token from the directive to which we are responding.
endpointThe AVSMessageEndpoint to identify the endpoint related to this event.
responseNamespacea string containing the namespace for this response.
jsonPayloada payload containing the error type and message (optional).
Returns
true if the message was enqueued successfully, false otherwise.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface.

◆ sendResponseEvent() [1/2]

bool alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::sendResponseEvent ( const std::string &  instance,
const std::string &  correlationToken,
const avsCommon::avs::AVSMessageEndpoint endpoint,
const std::string &  jsonPayload = "{}" 
)
overridevirtual

Send an Alexa.Response event. Since these events require context, the event will be enqueued and this method will return immediately (non-blocking). The message will be sent once context has been received from ContextManager.

Parameters
instanceThe instance ID of the responding capability.
correlationTokenThe correlation token from the directive to which we are responding.
endpointThe AVSMessageEndpoint to identify the endpoint related to this event.
jsonPayloada JSON string representing the payload for the response event (optional).
Returns
true if the event was successfuly enqueued, false on failure.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface.

◆ sendResponseEvent() [2/2]

bool alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::sendResponseEvent ( const std::string &  instance,
const std::string &  correlationToken,
const avsCommon::avs::AVSMessageEndpoint endpoint,
const std::string &  responseNamespace,
const std::string &  responseName,
const std::string &  jsonPayload = "{}" 
)
overridevirtual

Send an Response event. Since these events require context, the event will be enqueued and this method will return immediately (non-blocking). The message will be sent once context has been received from ContextManager.

Parameters
instanceThe instance ID of the responding capability.
correlationTokenThe correlation token from the directive to which we are responding.
endpointThe AVSMessageEndpoint to identify the endpoint related to this event.
responseNamespaceThe namespace of response event
responseNameThe name of response event
jsonPayloada JSON string representing the payload for the response event (optional).
Returns
true if the event was successfuly enqueued, false on failure.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AlexaInterfaceMessageSenderInterface.

◆ sendStateReportEvent()

bool alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSender::sendStateReportEvent ( const std::string &  instance,
const std::string &  correlationToken,
const avsCommon::avs::AVSMessageEndpoint endpoint 
)
overridevirtual

Send an Alexa.StateReport event. Since these events require context, the event will be enqueued and this method will return immediately. The event will be sent once context has been received from ContextManager.

Parameters
instanceThe instance ID of the responding capability.
correlationTokenThe correlation token from the directive to which we are responding.
endpointThe AVSMessageEndpoint to identify the endpoint related to this event.
Returns
true if the event was successfuly enqueued, false on failure.

Implements alexaClientSDK::capabilityAgents::alexa::AlexaInterfaceMessageSenderInternalInterface.


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

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