AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <MessageRouter.h>
Public Member Functions | |
MessageRouter (std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > authDelegate, std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > attachmentManager, std::shared_ptr< TransportFactoryInterface > transportFactory, const std::string &avsGateway="", int engineType=avsCommon::sdkInterfaces::ENGINE_TYPE_ALEXA_VOICE_SERVICES, std::chrono::milliseconds serverSideDisconnectGracePeriod=DEFAULT_SERVER_SIDE_DISCONNECT_GRACE_PERIOD) | |
void | onConnected (std::shared_ptr< TransportInterface > transport) override |
void | onDisconnected (std::shared_ptr< TransportInterface > transport, avsCommon::sdkInterfaces::ConnectionStatusObserverInterface::ChangedReason reason) override |
void | onServerSideDisconnect (std::shared_ptr< TransportInterface > transport) override |
void | consumeMessage (const std::string &contextId, const std::string &message) override |
void | doShutdown () override |
MessageRouterInterface methods. | |
void | enable () override |
void | disable () override |
ConnectionStatus | getConnectionStatus () override |
void | sendMessage (std::shared_ptr< avsCommon::avs::MessageRequest > request) override |
void | setAVSGateway (const std::string &avsGateway) override |
std::string | getAVSGateway () override |
void | onWakeConnectionRetry () override |
void | onWakeVerifyConnectivity () override |
void | setObserver (std::shared_ptr< MessageRouterObserverInterface > observer) override |
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 |
Public Member Functions inherited from alexaClientSDK::acl::TransportObserverInterface | |
virtual | ~TransportObserverInterface ()=default |
Static Public Member Functions | |
static std::shared_ptr< MessageRouterInterface > | createMessageRouterInterface (const std::shared_ptr< acsdkShutdownManagerInterfaces::ShutdownNotifierInterface > &shutdownNotifier, const std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > &authDelegate, const std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > &attachmentManager, const std::shared_ptr< TransportFactoryInterface > &transportFactory) |
Static Public Attributes | |
static const std::chrono::milliseconds | DEFAULT_SERVER_SIDE_DISCONNECT_GRACE_PERIOD |
Amount of time to allow for an automatic reconnect before notifying of a server side disconnect. More... | |
Protected Attributes | |
avsCommon::utils::threading::Executor | m_executor |
Additional Inherited Members |
This an abstract base class which specifies the interface to manage an actual connection over some medium to AVS.
Implementations of this class are required to be thread-safe.
alexaClientSDK::acl::MessageRouter::MessageRouter | ( | std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > | authDelegate, |
std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > | attachmentManager, | ||
std::shared_ptr< TransportFactoryInterface > | transportFactory, | ||
const std::string & | avsGateway = "" , |
||
int | engineType = avsCommon::sdkInterfaces::ENGINE_TYPE_ALEXA_VOICE_SERVICES , |
||
std::chrono::milliseconds | serverSideDisconnectGracePeriod = DEFAULT_SERVER_SIDE_DISCONNECT_GRACE_PERIOD |
||
) |
Constructor.
authDelegate | An implementation of an AuthDelegate, which will provide valid access tokens with which the MessageRouter can authorize the client to AVS. |
attachmentManager | The AttachmentManager, which allows ACL to write attachments received from AVS. |
transportFactory | Factory used to create new transport objects. |
avsGateway | The gateway to connect to AVS. The value will be set by the AVSGatewayManager based on either the previously verified gateway or a value from the config file. If both are not present, a default value is used. |
engineType | optional parameter of engine type associated with this MessageRouter. Default to be ENGINE_TYPE_ALEXA_VOICE_SERVICES. |
serverSideDisconnectGracePeriod | How long to allow for an automatic reconnection before reporting a server side disconnect to our observer. |
|
overridevirtual |
Called when a message has been received from AVS.
contextId | The context id for the current message. |
message | The AVS message in string representation. |
Implements alexaClientSDK::acl::MessageConsumerInterface.
|
static |
Factory function for creating an instance of MessageRouterInterface.
shutdownNotifier | The object with which to register to be told when to shut down. |
authDelegate | An implementation of an AuthDelegate, which will provide valid access tokens with which the MessageRouter can authorize the client to AVS. |
attachmentManager | The AttachmentManager, which allows ACL to write attachments received from AVS. |
transportFactory | Factory used to create new transport objects. |
|
overridevirtual |
Close the AVS connection. If the underlying implementation is not connected, or is in the process of changing its connection state, this function should do nothing.
Implements alexaClientSDK::acl::MessageRouterInterface.
|
overridevirtual |
Prepares/enables this object to be deleted. This should be the last function called on this object prior to deleting (or resetting) its shared_ptr.
Implements alexaClientSDK::avsCommon::utils::RequiresShutdown.
|
overridevirtual |
Begin the process of establishing an AVS connection. If the underlying implementation is already connected, or is in the process of changing its connection state, this function should do nothing.
Implements alexaClientSDK::acl::MessageRouterInterface.
|
overridevirtual |
Get the gateway URL for the AVS connection.
Implements alexaClientSDK::acl::MessageRouterInterface.
|
overridevirtual |
Queries the status of the connection.
Implements alexaClientSDK::acl::MessageRouterInterface.
|
overridevirtual |
Called when a connection to AVS is established.
transport | The transport that has connected. |
Implements alexaClientSDK::acl::TransportObserverInterface.
|
overridevirtual |
Called when we disconnect from AVS.
transport | The transport that is no longer connected (or attempting to connect). |
reason | The reason that we disconnected. |
Implements alexaClientSDK::acl::TransportObserverInterface.
|
overridevirtual |
Called when the server asks the client to reconnect
transport | The transport that has received the disconnect request. |
Implements alexaClientSDK::acl::TransportObserverInterface.
|
overridevirtual |
This method is a hint to retry connecting (if not connected).
Implements alexaClientSDK::acl::MessageRouterInterface.
|
overridevirtual |
This method is a hint to verify that there is a valid connection to AVS.
Implements alexaClientSDK::acl::MessageRouterInterface.
|
override |
|
overridevirtual |
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.
avsGateway | The URL for the new AVS gateway. |
Implements alexaClientSDK::acl::MessageRouterInterface.
|
overridevirtual |
Set the observer to this object.
observer | An observer to this class, which will be notified when the connection status changes, and when messages arrive from AVS. |
Implements alexaClientSDK::acl::MessageRouterInterface.
|
static |
Amount of time to allow for an automatic reconnect before notifying of a server side disconnect.
|
protected |
Executor to perform asynchronous operations:
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0