AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <AVSConnectionManager.h>
Public Member Functions | |
AVSConnectionManagerInterface method overrides. | |
void | enable () override |
void | disable () override |
bool | isEnabled () override |
void | reconnect () override |
bool | isConnected () const override |
void | onWakeConnectionRetry () override |
void | addMessageObserver (std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > observer) override |
void | removeMessageObserver (std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > observer) override |
MessageSenderInterface methods. | |
void | sendMessage (std::shared_ptr< avsCommon::avs::MessageRequest > request) override |
AVSGatewayAssignerInterface methods. | |
void | setAVSGateway (const std::string &avsGateway) override |
std::string | getAVSGateway () const override |
InternetConnectionObserverInterface method overrides. | |
void | onConnectionStatusChanged (bool connected) override |
Public Member Functions inherited from alexaClientSDK::avsCommon::avs::AbstractAVSConnectionManager | |
AbstractAVSConnectionManager (std::unordered_set< std::shared_ptr< ConnectionStatusObserverInterface >> observers=std::unordered_set< std::shared_ptr< ConnectionStatusObserverInterface >>()) | |
virtual | ~AbstractAVSConnectionManager ()=default |
void | addConnectionStatusObserver (std::shared_ptr< ConnectionStatusObserverInterface > observer) override |
void | removeConnectionStatusObserver (std::shared_ptr< ConnectionStatusObserverInterface > observer) override |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface | |
virtual | ~AVSConnectionManagerInterface ()=default |
virtual void | addConnectionStatusObserver (std::shared_ptr< ConnectionStatusObserverInterface > observer)=0 |
virtual void | removeConnectionStatusObserver (std::shared_ptr< ConnectionStatusObserverInterface > observer)=0 |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayAssignerInterface | |
virtual | ~AVSGatewayAssignerInterface ()=default |
Destructor. More... | |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::InternetConnectionObserverInterface | |
virtual | ~InternetConnectionObserverInterface ()=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 |
Static Public Member Functions | |
static std::shared_ptr< MessageSenderInterface > | createMessageSenderInterface (const std::shared_ptr< AVSConnectionManagerInterface > &connectionManager) |
static std::shared_ptr< AVSConnectionManagerInterface > | createAVSConnectionManagerInterface (const std::shared_ptr< acsdkShutdownManagerInterfaces::ShutdownNotifierInterface > &shutdownNotifier, const std::shared_ptr< MessageRouterInterface > &messageRouter, const std::shared_ptr< avsCommon::sdkInterfaces::InternetConnectionMonitorInterface > &internetConnectionMonitor) |
static std::shared_ptr< AVSConnectionManager > | create (std::shared_ptr< MessageRouterInterface > messageRouter, bool isEnabled=true, std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface >> connectionStatusObservers=std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface >>(), std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface >> messageObservers=std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface >>(), std::shared_ptr< avsCommon::sdkInterfaces::InternetConnectionMonitorInterface > internetConnectionMonitor=nullptr) |
This class is designed to manage a connection with AVS seamlessly for the client, internally taking care of the following idiosyncracies:
The api provided by this class is designed around the above feature set. As such, there is no explicit 'connect' function, but rather if an object of this class is enabled, then that object will attempt to make a connection to AVS on the client's behalf.
If the client wishes the object to not connect to AVS, or to disconnect from AVS at any time, the 'disable' function should be called.
If the client wishes the object to either break the current connection to AVS and create a new one, or that the object should try a reconnect immediately from a non-connected (but perhaps in an internally waiting state), then the 'reconnect' function should be called.
Finally, the client may send outgoing messages to AVS via the non-blocking 'send' function.
Credentials to authenticate the client with AVS must be provided by an implementation of the AuthDelegate class.
This SDK also provides observer interfaces for classes that may be notified when the connection status changes, and when messages are received from AVS. These observer objects are optional.
|
overridevirtual |
Adds an observer to be notified of message receptions.
observer | The observer object to add. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
static |
A factory function that creates an AVSConnectionManager object.
messageRouter | The entity which handles sending and receiving of AVS messages. |
isEnabled | The enablement setting. If true, then the created object will attempt to connect to AVS. |
connectionStatusObservers | An optional set of observers which will be notified when the connection status changes. The observers cannot be a nullptr. |
messageObservers | An optional set of observer which will be sent messages that arrive from AVS. The observers cannot be a nullptr. |
internetConnectionMonitor | The object to use to monitor connectivity with the internet. |
|
static |
A factory function that creates an instance of AVSConnectionManagerInterface.
shutdownNotifier | The object with which to register to be told when to shut down. |
messageRouter | The entity which handles sending and receiving of AVS messages. |
internetConnectionMonitor | The iobject to use to monitor connectivity with the internet. |
|
static |
A factory function that forwards an instance of AVSConnectionManagerInterface
to a MessageSenderInterface
.
connectionManager | The MessageSenderInterface implementation to forward. |
MessageSenderInterface
.
|
overridevirtual |
Disable the AVSConnectionManager object. If the object is currently connected to AVS, then calling this function will cause the connection to be closed. If the object is not connected, then calling this function will do nothing.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
overridevirtual |
Enable the AVSConnectionManager object to make connections to AVS. Once enabled, the object will attempt to create a connection to AVS. If the object is already connected, this function will do nothing.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
overridevirtual |
Gets the current gateway URL for AVS connection.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayAssignerInterface.
|
overridevirtual |
Returns whether the AVS connection is established. If the connection is pending, false
will be returned.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
overridevirtual |
Returns if the object is enabled for making connections to AVS.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
overridevirtual |
Take necessary actions as a result of an internet connection change.
connected | Whether or not we are currently connected to the internet. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::InternetConnectionObserverInterface.
|
overridevirtual |
This method is a hint to retry connecting (if not connected).
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
overridevirtual |
This function causes the object, if enabled, to create new connection to AVS. If the object is already connected, then that connection will be closed and a new one created. If the object is not connected, but perhaps in the process of waiting for its next connection attempt, then its waiting policy will be reset and it will attempt to create a new connection immediately. If the object is disabled, then this function will do nothing.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
overridevirtual |
Removes an observer from being notified of message receptions.
observer | The observer object to remove. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.
|
override |
|
overridevirtual |
Set AVS gateway as the given parameter
avsGateway | AVS gateway to set. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayAssignerInterface.
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0