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

#include <HTTP2Transport.h>

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

Classes

struct  Configuration
 

Public Member Functions

void addObserver (std::shared_ptr< TransportObserverInterface > transportObserver)
 
void removeObserver (std::shared_ptr< TransportObserverInterface > observer)
 
std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionInterfacegetHTTP2Connection ()
 
TransportInterface methods.
bool connect () override
 
void disconnect () override
 
bool isConnected () override
 
void onRequestEnqueued () override
 
void onWakeConnectionRetry () override
 
void onWakeVerifyConnectivity () override
 
MessageSenderInterface methods.

HTTP2Transport uses sendMessage to handle the post-connect state only.

void sendMessage (std::shared_ptr< avsCommon::avs::MessageRequest > request) override
 
PostConnectObserverInterface methods.
void onPostConnected () override
 
void onUnRecoverablePostConnectFailure () override
 
AuthObserverInterface methods
void onAuthStateChange (avsCommon::sdkInterfaces::AuthObserverInterface::State newState, avsCommon::sdkInterfaces::AuthObserverInterface::Error error) override
 
RequiresShutdown methods.
void doShutdown () override
 
{ ExchangeHandlerContextInterface methods.
void onDownchannelConnected () override
 
void onDownchannelFinished () override
 
void onMessageRequestSent (const std::shared_ptr< avsCommon::avs::MessageRequest > &request) override
 
void onMessageRequestTimeout () override
 
void onMessageRequestAcknowledged (const std::shared_ptr< avsCommon::avs::MessageRequest > &request) override
 
void onMessageRequestFinished () override
 
void onPingRequestAcknowledged (bool success) override
 
void onPingTimeout () override
 
void onActivity () override
 
void onForbidden (const std::string &authToken="") override
 
std::shared_ptr< avsCommon::utils::http2::HTTP2RequestInterfacecreateAndSendRequest (const avsCommon::utils::http2::HTTP2RequestConfig &cfg) override
 
std::string getAVSGateway () override
 
HTTP2ConnectionObserverInterface methods.
void onGoawayReceived () override
 
- Public Member Functions inherited from alexaClientSDK::acl::TransportInterface
 TransportInterface ()
 
 TransportInterface (const TransportInterface &rhs)=delete
 
TransportInterfaceoperator= (const TransportInterface &rhs)=delete
 
virtual ~TransportInterface ()=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
 
- Public Member Functions inherited from alexaClientSDK::acl::PostConnectObserverInterface
virtual ~PostConnectObserverInterface ()=default
 
- 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::AuthObserverInterface
virtual ~AuthObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::http2::HTTP2ConnectionObserverInterface
virtual ~HTTP2ConnectionObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::acl::ExchangeHandlerContextInterface
virtual ~ExchangeHandlerContextInterface ()=default
 

Static Public Member Functions

static std::shared_ptr< HTTP2Transportcreate (std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > authDelegate, const std::string &avsGateway, std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionInterface > http2Connection, std::shared_ptr< MessageConsumerInterface > messageConsumer, std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > attachmentManager, std::shared_ptr< TransportObserverInterface > transportObserver, std::shared_ptr< PostConnectFactoryInterface > postConnectFactory, std::shared_ptr< SynchronizedMessageRequestQueue > sharedRequestQueue, Configuration configuration=Configuration(), std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr, std::shared_ptr< avsCommon::sdkInterfaces::EventTracerInterface > eventTracer=nullptr)
 

Friends

std::ostream & operator<< (std::ostream &stream, HTTP2Transport::State state)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface
enum  State {
  State::UNINITIALIZED, State::REFRESHED, State::EXPIRED, State::UNRECOVERABLE_ERROR,
  State::AUTHORIZING
}
 The enum State describes the state of authorization. More...
 
enum  Error {
  Error::SUCCESS, Error::UNKNOWN_ERROR, Error::AUTHORIZATION_FAILED, Error::UNAUTHORIZED_CLIENT,
  Error::SERVER_ERROR, Error::INVALID_REQUEST, Error::INVALID_VALUE, Error::AUTHORIZATION_EXPIRED,
  Error::UNSUPPORTED_GRANT_TYPE, Error::INVALID_CODE_PAIR, Error::AUTHORIZATION_PENDING, Error::SLOW_DOWN,
  Error::INTERNAL_ERROR, Error::INVALID_CBL_CLIENT_ID
}
 The enum Error encodes possible errors which may occur when changing state. More...
 

Detailed Description

Class to create and manage an HTTP/2 connection to AVS.

Member Function Documentation

◆ addObserver()

void alexaClientSDK::acl::HTTP2Transport::addObserver ( std::shared_ptr< TransportObserverInterface transportObserver)

Method to add a TransportObserverInterface instance.

Parameters
transportObserverThe observer instance to add.

◆ connect()

bool alexaClientSDK::acl::HTTP2Transport::connect ( )
overridevirtual

Initiate a connection to AVS. This function may operate asynchronously, meaning its return value does not imply a successful connection, but that an attempt to connect has been successfully started. This function may not be thread-safe.

Returns
If connection setup was successful.

Implements alexaClientSDK::acl::TransportInterface.

◆ create()

static std::shared_ptr<HTTP2Transport> alexaClientSDK::acl::HTTP2Transport::create ( std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface authDelegate,
const std::string &  avsGateway,
std::shared_ptr< avsCommon::utils::http2::HTTP2ConnectionInterface http2Connection,
std::shared_ptr< MessageConsumerInterface messageConsumer,
std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface attachmentManager,
std::shared_ptr< TransportObserverInterface transportObserver,
std::shared_ptr< PostConnectFactoryInterface postConnectFactory,
std::shared_ptr< SynchronizedMessageRequestQueue sharedRequestQueue,
Configuration  configuration = Configuration(),
std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder = nullptr,
std::shared_ptr< avsCommon::sdkInterfaces::EventTracerInterface eventTracer = nullptr 
)
static

A function that creates a HTTP2Transport object.

Parameters
authDelegateThe AuthDelegate implementation.
avsGatewayThe URL for the AVS gateway of this object.
http2ConnectionInstance of HTTP2ConnectionInterface with which to perform HTTP2 operations.
messageConsumerThe MessageConsumerInterface to pass messages to.
attachmentManagerThe attachment manager that manages the attachments.
transportObserverThe observer of the new instance of TransportInterface.
postConnectFactoryThe object used to create PostConnectInterface instances.
sharedRequestQueueRequest queue shared by all instances of HTTPTransportInterface.
configurationAn optional configuration to specify HTTP2/2 connection settings.
metricRecorderThe metric recorder.
eventTracerThe object used to trace events sent to AVS.
Returns
A shared pointer to a HTTP2Transport object.

◆ createAndSendRequest()

std::shared_ptr<avsCommon::utils::http2::HTTP2RequestInterface> alexaClientSDK::acl::HTTP2Transport::createAndSendRequest ( const avsCommon::utils::http2::HTTP2RequestConfig cfg)
overridevirtual

Create an HTTP2Request for this HTTP2Transport.

Parameters
cfgThe configuration object which defines the request.
Returns
The new instance of HTTP2RequestInterface, or nullptr if the operation failed.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ disconnect()

void alexaClientSDK::acl::HTTP2Transport::disconnect ( )
overridevirtual

Disconnect from AVS. This function may not be thread-safe.

Implements alexaClientSDK::acl::TransportInterface.

◆ doShutdown()

void alexaClientSDK::acl::HTTP2Transport::doShutdown ( )
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.

Warning
  • Attempting to call functions on this object after calling shutdown() can result in undefined behavior.
  • Neglecting to call shutdown() on this object can result in resource leaks or other undefined behavior.

Implements alexaClientSDK::avsCommon::utils::RequiresShutdown.

◆ getAVSGateway()

std::string alexaClientSDK::acl::HTTP2Transport::getAVSGateway ( )
overridevirtual

Get AVS gateway to send request to.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ getHTTP2Connection()

std::shared_ptr<avsCommon::utils::http2::HTTP2ConnectionInterface> alexaClientSDK::acl::HTTP2Transport::getHTTP2Connection ( )

Get the HTTP2ConnectionInterface instance being used by this HTTP2Transport.

Returns
The HTTP2ConnectionInterface instance being used by this HTTP2Transport.

◆ isConnected()

bool alexaClientSDK::acl::HTTP2Transport::isConnected ( )
overridevirtual

Returns whether this object is currently connected to AVS.

Returns
If the object is currently connected to AVS.

Implements alexaClientSDK::acl::TransportInterface.

◆ onActivity()

void alexaClientSDK::acl::HTTP2Transport::onActivity ( )
overridevirtual

Notification of network activity between this client and AVS. (this is used to detect sustained inactivity requiring the send of a ping).

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onAuthStateChange()

void alexaClientSDK::acl::HTTP2Transport::onAuthStateChange ( avsCommon::sdkInterfaces::AuthObserverInterface::State  newState,
avsCommon::sdkInterfaces::AuthObserverInterface::Error  error 
)
overridevirtual

Notification that an authorization state has changed.

Note
Implementations of this method must not call AuthDelegate methods because the AuthDelegate may be in a 'locked' state at the time this call is made.
Parameters
newStateThe new state of the authorization token.
errorThe error associated to the state change.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AuthObserverInterface.

◆ onDownchannelConnected()

void alexaClientSDK::acl::HTTP2Transport::onDownchannelConnected ( )
overridevirtual

Notification that the downchannel has been established.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onDownchannelFinished()

void alexaClientSDK::acl::HTTP2Transport::onDownchannelFinished ( )
overridevirtual

Notification that the downchannel has failed to be established or has disconnected.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onForbidden()

void alexaClientSDK::acl::HTTP2Transport::onForbidden ( const std::string &  authToken = "")
overridevirtual

Notification that a request received a FORBIDDEN (403) response.

Parameters
authTokenThe auth token used for the forbidden request or an empty string if the token is not specified.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onGoawayReceived()

void alexaClientSDK::acl::HTTP2Transport::onGoawayReceived ( )
overridevirtual

Notify that a GOAWAY frame has been received.

Implements alexaClientSDK::avsCommon::utils::http2::HTTP2ConnectionObserverInterface.

◆ onMessageRequestAcknowledged()

void alexaClientSDK::acl::HTTP2Transport::onMessageRequestAcknowledged ( const std::shared_ptr< avsCommon::avs::MessageRequest > &  request)
overridevirtual

Notification that sending a MessageRequest has failed or been acknowledged by AVS (this is used to indicate it is okay to send the next message).

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onMessageRequestFinished()

void alexaClientSDK::acl::HTTP2Transport::onMessageRequestFinished ( )
overridevirtual

Notification tht a message request has finished it's exchange with AVS.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onMessageRequestSent()

void alexaClientSDK::acl::HTTP2Transport::onMessageRequestSent ( const std::shared_ptr< avsCommon::avs::MessageRequest > &  request)
overridevirtual

Notification that an MessageRequest has been sent.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onMessageRequestTimeout()

void alexaClientSDK::acl::HTTP2Transport::onMessageRequestTimeout ( )
overridevirtual

Notification that sending a message request timed out.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onPingRequestAcknowledged()

void alexaClientSDK::acl::HTTP2Transport::onPingRequestAcknowledged ( bool  success)
overridevirtual

Notification that sending a ping to AVS has failed or been acknowledged by AVS.

Parameters
successWhether the ping was acknowledged successfully.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onPingTimeout()

void alexaClientSDK::acl::HTTP2Transport::onPingTimeout ( )
overridevirtual

Notification that a ping request timed out.

Implements alexaClientSDK::acl::ExchangeHandlerContextInterface.

◆ onPostConnected()

void alexaClientSDK::acl::HTTP2Transport::onPostConnected ( )
overridevirtual

◆ onRequestEnqueued()

void alexaClientSDK::acl::HTTP2Transport::onRequestEnqueued ( )
overridevirtual

A message request has been added to the shared synchronized queue and is ready to be read.

Implements alexaClientSDK::acl::TransportInterface.

◆ onUnRecoverablePostConnectFailure()

void alexaClientSDK::acl::HTTP2Transport::onUnRecoverablePostConnectFailure ( )
overridevirtual

Called when a PostConnect object failed to complete the post-connect processing.

Implements alexaClientSDK::acl::PostConnectObserverInterface.

◆ onWakeConnectionRetry()

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

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

Implements alexaClientSDK::acl::TransportInterface.

◆ onWakeVerifyConnectivity()

void alexaClientSDK::acl::HTTP2Transport::onWakeVerifyConnectivity ( )
overridevirtual

This method is a hint to verify that there is a valid connection ot AVS.

Implements alexaClientSDK::acl::TransportInterface.

◆ removeObserver()

void alexaClientSDK::acl::HTTP2Transport::removeObserver ( std::shared_ptr< TransportObserverInterface observer)

Method to remove a TransportObserverInterface instance.

Parameters
observerThe observer instance to remove.

◆ sendMessage()

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

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
HTTP2Transport::State  state 
)
friend

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

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