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

#include <DialogUXStateAggregator.h>

Inheritance diagram for alexaClientSDK::avsCommon::avs::DialogUXStateAggregator:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::avsCommon::avs::DialogUXStateAggregator:
Collaboration graph
[legend]

Public Member Functions

 DialogUXStateAggregator (std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr, std::chrono::milliseconds timeoutForThinkingToIdle=std::chrono::seconds{8}, std::chrono::milliseconds timeoutForListeningToIdle=std::chrono::seconds{8})
 
void addObserver (std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface > observer)
 
void removeObserver (std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface > observer)
 
void onStateChanged (sdkInterfaces::AudioInputProcessorObserverInterface::State state) override
 
void onStateChanged (sdkInterfaces::SpeechSynthesizerObserverInterface::SpeechSynthesizerState state, const avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId mediaSourceId, const avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState > &mediaPlayerState, const std::vector< avsCommon::utils::audioAnalyzer::AudioAnalyzerState > &audioAnalyzerState) override
 
void receive (const std::string &contextId, const std::string &message) override
 
InteractionModelRequestProcessingObserverInterface Functions
void onRequestProcessingStarted () override
 
void onRequestProcessingCompleted () override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
virtual ~AudioInputProcessorObserverInterface ()=default
 Destructor. More...
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::SpeechSynthesizerObserverInterface
virtual ~SpeechSynthesizerObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::MessageObserverInterface
virtual ~MessageObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
virtual ~ConnectionStatusObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::InteractionModelRequestProcessingObserverInterface
virtual ~InteractionModelRequestProcessingObserverInterface ()=default
 Destructor. More...
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
enum  State { State::IDLE, State::EXPECTING_SPEECH, State::RECOGNIZING, State::BUSY }
 The different states the AudioInputProcessor can be in. More...
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::SpeechSynthesizerObserverInterface
enum  SpeechSynthesizerState {
  SpeechSynthesizerState::PLAYING, SpeechSynthesizerState::FINISHED, SpeechSynthesizerState::INTERRUPTED, SpeechSynthesizerState::GAINING_FOCUS,
  SpeechSynthesizerState::LOSING_FOCUS
}
 
- 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
}
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
static std::string stateToString (State state)
 

Detailed Description

This class serves as a component to aggregate other observer interfaces into one UX component that notifies observers of AVS dialog specific UX changes based on events that occur within these components.

Constructor & Destructor Documentation

◆ DialogUXStateAggregator()

alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::DialogUXStateAggregator ( std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder = nullptr,
std::chrono::milliseconds  timeoutForThinkingToIdle = std::chrono::seconds{8},
std::chrono::milliseconds  timeoutForListeningToIdle = std::chrono::seconds{8} 
)

Constructor.

Note: Additional parameters to this class must be added before the timeout parameters

Parameters
metricRecorderThe metric recorder.
timeoutForThinkingToIdleThis timeout will be used to time out from the THINKING state in case no messages arrive from AVS.
timeoutForListeningToIdleThis timeout will be used to time out from the LISTENING state in case the Request Processing Started (RPS) directive is not received from AVS.

Member Function Documentation

◆ addObserver()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::addObserver ( std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface observer)

Adds an observer to be notified of UX state changes.

Warning
The user of this class must make sure that the observer remains valid until the destruction of this object as state changes may come in at any time, leading to callbacks to the observer. Failure to do so may result in crashes when this class attempts to access its observers.
Parameters
observerThe new observer to notify of UX state changes.

◆ onRequestProcessingCompleted()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onRequestProcessingCompleted ( )
overridevirtual

Used to notify the observer that a Request Processing Completed was received.

Implements alexaClientSDK::avsCommon::sdkInterfaces::InteractionModelRequestProcessingObserverInterface.

◆ onRequestProcessingStarted()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onRequestProcessingStarted ( )
overridevirtual

Used to notify the observer that a Request Processing Started was received.

Implements alexaClientSDK::avsCommon::sdkInterfaces::InteractionModelRequestProcessingObserverInterface.

◆ onStateChanged() [1/2]

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onStateChanged ( sdkInterfaces::AudioInputProcessorObserverInterface::State  state)
overridevirtual

This function is called when the state of the observed AudioInputProcessor changes. This function will block processing of audio inputs, so implementations should return quickly.

Parameters
stateThe new state of the AudioInputProcessor.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface.

◆ onStateChanged() [2/2]

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onStateChanged ( sdkInterfaces::SpeechSynthesizerObserverInterface::SpeechSynthesizerState  state,
const avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId  mediaSourceId,
const avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState > &  mediaPlayerState,
const std::vector< avsCommon::utils::audioAnalyzer::AudioAnalyzerState > &  audioAnalyzerState 
)
overridevirtual

Notification that the SpeechSynthesizer state has changed. Callback functions must return as soon as possible.

Parameters
stateThe new state of the speechSynthesizer.
mediaSourceIdThe current media source id for SpeechSynthesizer
mediaPlayerStateOptional state of the media player as of this state change. The Optional is blank if the state is unavailable.
audioAnalyzerStatestates of the audio analyzers related to the speech output.

Implements alexaClientSDK::avsCommon::sdkInterfaces::SpeechSynthesizerObserverInterface.

◆ receive()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::receive ( const std::string &  contextId,
const std::string &  message 
)
overridevirtual

A function that a client must implement to receive Messages from AVS.

Parameters
contextIdThe context for the message, which in this case reflects the logical HTTP/2 stream the message arrived on.
messageThe AVS message that has been received.

Implements alexaClientSDK::avsCommon::sdkInterfaces::MessageObserverInterface.

◆ removeObserver()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::removeObserver ( std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface observer)

Removes an observer from the internal collection of observers synchronously. If the observer is not present, nothing will happen.

Note
This is a synchronous call which can not be made by an observer callback. Attempting to call removeObserver() from DialogUXStateObserverInterface::onDialogUXStateChanged() will result in a deadlock.
Parameters
observerThe observer to remove.

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