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

#include <AVSConnectionManager.h>

Inheritance diagram for alexaClientSDK::acl::AVSConnectionManager:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::acl::AVSConnectionManager:
Collaboration graph
[legend]

Public Member Functions

void sendMessage (std::shared_ptr< avsCommon::avs::MessageRequest > request) override
 
void setAVSGateway (const std::string &avsGateway) override
 
std::string getAVSGateway ()
 
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
 
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::MessageSenderInterface
virtual ~MessageSenderInterface ()=default
 Destructor. More...
 
virtual void sendMessage (std::shared_ptr< avs::MessageRequest > request)=0
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayAssignerInterface
virtual ~AVSGatewayAssignerInterface ()=default
 Destructor. More...
 
- Public Member Functions inherited from alexaClientSDK::acl::MessageRouterObserverInterface
virtual ~MessageRouterObserverInterface ()=default
 
- 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< AVSConnectionManagercreate (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)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::avs::AbstractAVSConnectionManager
using ConnectionStatusObserverInterface = avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
 Type alias for brevity. More...
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface
using ConnectionStatusObserverInterface = avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
 Type alias for brevity. More...
 
- Protected Member Functions inherited from alexaClientSDK::avsCommon::avs::AbstractAVSConnectionManager
void updateConnectionStatus (ConnectionStatusObserverInterface::Status status, ConnectionStatusObserverInterface::ChangedReason reason)
 
void notifyObservers ()
 
void clearObservers ()
 
- Protected Attributes inherited from alexaClientSDK::avsCommon::avs::AbstractAVSConnectionManager
std::mutex m_mutex
 Mutex to protect access to data members. More...
 
ConnectionStatusObserverInterface::Status m_connectionStatus
 The current connection status. m_mutex must be acquired before access. More...
 
ConnectionStatusObserverInterface::ChangedReason m_connectionChangedReason
 The reason we changed to the current connection status. m_mutex must be acquired before access. More...
 
std::unordered_set< std::shared_ptr< ConnectionStatusObserverInterface > > m_connectionStatusObservers
 Set of observers to notify when the connection status changes. m_mutex must be acquired before access. More...
 

Detailed Description

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.

Member Function Documentation

◆ addMessageObserver()

void alexaClientSDK::acl::AVSConnectionManager::addMessageObserver ( std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface observer)
overridevirtual

Adds an observer to be notified of message receptions.

Parameters
observerThe observer object to add.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.

◆ create()

std::shared_ptr< AVSConnectionManager > alexaClientSDK::acl::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 
)
static

A factory function that creates an AVSConnectionManager object.

Parameters
messageRouterThe entity which handles sending and receiving of AVS messages.
isEnabledThe enablement setting. If true, then the created object will attempt to connect to AVS.
connectionStatusObserversAn optional set of observers which will be notified when the connection status changes. The observers cannot be a nullptr.
messageObserversAn optional set of observer which will be sent messages that arrive from AVS. The observers cannot be a nullptr.
Returns
The created AVSConnectionManager object.

◆ disable()

void alexaClientSDK::acl::AVSConnectionManager::disable ( )
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.

◆ enable()

void alexaClientSDK::acl::AVSConnectionManager::enable ( )
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.

◆ getAVSGateway()

std::string alexaClientSDK::acl::AVSConnectionManager::getAVSGateway ( )
Returns
The current gateway URL for AVS connection.

◆ isConnected()

bool alexaClientSDK::acl::AVSConnectionManager::isConnected ( ) const
overridevirtual

Returns whether the AVS connection is established. If the connection is pending, false will be returned.

Returns
Whether the AVS connection is established.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.

◆ isEnabled()

bool alexaClientSDK::acl::AVSConnectionManager::isEnabled ( )
overridevirtual

Returns if the object is enabled for making connections to AVS.

Returns
Whether this Connection object is enabled to make connections.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.

◆ onConnectionStatusChanged()

void alexaClientSDK::acl::AVSConnectionManager::onConnectionStatusChanged ( bool  connected)
overridevirtual

Take necessary actions as a result of an internet connection change.

Parameters
connectedWhether or not we are currently connected to the internet.

Implements alexaClientSDK::avsCommon::sdkInterfaces::InternetConnectionObserverInterface.

◆ onWakeConnectionRetry()

void alexaClientSDK::acl::AVSConnectionManager::onWakeConnectionRetry ( )
overridevirtual

This method is a hint to retry connecting (if not connected).

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.

◆ reconnect()

void alexaClientSDK::acl::AVSConnectionManager::reconnect ( )
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.

◆ removeMessageObserver()

void alexaClientSDK::acl::AVSConnectionManager::removeMessageObserver ( std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface observer)
overridevirtual

Removes an observer from being notified of message receptions.

Parameters
observerThe observer object to remove.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSConnectionManagerInterface.

◆ sendMessage()

void alexaClientSDK::acl::AVSConnectionManager::sendMessage ( std::shared_ptr< avsCommon::avs::MessageRequest request)
override

◆ setAVSGateway()

void alexaClientSDK::acl::AVSConnectionManager::setAVSGateway ( const std::string &  avsGateway)
overridevirtual
Note
Set the gateway URL for the AVS connection. Calling this function with a new value will cause the current active connection to be closed, and a new one opened to the new gateway.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AVSGatewayAssignerInterface.


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