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

#include <MessageRequest.h>

Inheritance diagram for alexaClientSDK::avsCommon::avs::MessageRequest:
Inheritance graph
[legend]

Classes

struct  NamedReader
 A struct to hold an AttachmentReader alongside its name. More...
 

Public Member Functions

 MessageRequest (const std::string &jsonContent, const std::string &uriPathExtension="")
 
 MessageRequest (const std::string &jsonContent, bool isSerialized, const std::string &uriPathExtension="", std::vector< std::pair< std::string, std::string >> headers={})
 
virtual ~MessageRequest ()
 
void addAttachmentReader (const std::string &name, std::shared_ptr< attachment::AttachmentReader > attachmentReader)
 
std::string getJsonContent () const
 
bool getIsSerialized () const
 
std::string getUriPathExtension () const
 
int attachmentReadersCount () const
 
std::shared_ptr< NamedReadergetAttachmentReader (size_t index)
 
virtual void sendCompleted (avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status status)
 
virtual void exceptionReceived (const std::string &exceptionMessage)
 
void addObserver (std::shared_ptr< avsCommon::sdkInterfaces::MessageRequestObserverInterface > observer)
 
void removeObserver (std::shared_ptr< avsCommon::sdkInterfaces::MessageRequestObserverInterface > observer)
 
const std::vector< std::pair< std::string, std::string > > & getHeaders () const
 

Protected Attributes

std::mutex m_observerMutex
 Mutex to guard access of m_observers. More...
 
std::unordered_set< std::shared_ptr< avsCommon::sdkInterfaces::MessageRequestObserverInterface > > m_observers
 Set of observers of MessageRequestObserverInterface. More...
 
std::string m_jsonContent
 The JSON content to be sent to AVS. More...
 
bool m_isSerialized
 True if sending this message must be serialized with sending other serialized messages. More...
 
std::string m_uriPathExtension
 The path extension to be appended to the base URL when sending. More...
 
std::vector< std::shared_ptr< NamedReader > > m_readers
 The AttachmentReaders of the Attachments data to be sent to AVS. More...
 
std::vector< std::pair< std::string, std::string > > m_headers
 Optional headers to send with this request to AVS. More...
 

Detailed Description

This is a wrapper class which allows a client to send a Message to AVS, and be notified when the attempt to send the Message was completed.

Constructor & Destructor Documentation

◆ MessageRequest() [1/2]

alexaClientSDK::avsCommon::avs::MessageRequest::MessageRequest ( const std::string &  jsonContent,
const std::string &  uriPathExtension = "" 
)

Constructor.

Parameters
jsonContentThe message to be sent to AVS.
uriPathExtensionAn optional uri path extension which will be appended to the base url of the AVS. endpoint. If not specified, the default AVS path extension should be used by the sender implementation.

◆ MessageRequest() [2/2]

alexaClientSDK::avsCommon::avs::MessageRequest::MessageRequest ( const std::string &  jsonContent,
bool  isSerialized,
const std::string &  uriPathExtension = "",
std::vector< std::pair< std::string, std::string >>  headers = {} 
)

Constructor.

Parameters
jsonContentThe message to be sent to AVS.
isSerializedTrue if sending this message must be serialized with sending other serialized messages.
uriPathExtensionAn optional uri path extension which will be appended to the base url of the AVS.
headerskey/value pairs of extra HTTP headers to use with this request. endpoint. If not specified, the default AVS path extension should be used by the sender implementation.

◆ ~MessageRequest()

alexaClientSDK::avsCommon::avs::MessageRequest::~MessageRequest ( )
virtual

Destructor.

Member Function Documentation

◆ addAttachmentReader()

void alexaClientSDK::avsCommon::avs::MessageRequest::addAttachmentReader ( const std::string &  name,
std::shared_ptr< attachment::AttachmentReader attachmentReader 
)

Adds an attachment reader to the message. The attachment data will be the next part in the message to be sent to AVS.

Note
: The order by which the message attachments sent to AVS is the one by which they have been added to it.
Parameters
nameThe name of the message part containing the attachment data.
attachmentReaderThe attachment data to be sent to AVS along with the message.

◆ addObserver()

void alexaClientSDK::avsCommon::avs::MessageRequest::addObserver ( std::shared_ptr< avsCommon::sdkInterfaces::MessageRequestObserverInterface observer)

Add observer of MessageRequestObserverInterface.

Parameters
observerThe observer to be added to the set.

◆ attachmentReadersCount()

int alexaClientSDK::avsCommon::avs::MessageRequest::attachmentReadersCount ( ) const

Gets the number of AttachmentReaders in this message.

Returns
The number of readers in this message.

◆ exceptionReceived()

void alexaClientSDK::avsCommon::avs::MessageRequest::exceptionReceived ( const std::string &  exceptionMessage)
virtual

This function will be called if AVS responds with an exception message to this message request being sent.

Parameters
exceptionMessageThe exception message.

Reimplemented in alexaClientSDK::integration::ObservableMessageRequest.

◆ getAttachmentReader()

std::shared_ptr< MessageRequest::NamedReader > alexaClientSDK::avsCommon::avs::MessageRequest::getAttachmentReader ( size_t  index)

Retrieves the ith AttachmentReader in the message.

Parameters
indexThe index of the AttachmentReader to retrieve.
Returns
NamedReader of the ith attachment in the message. A null pointer is returned when index is out of bound.

◆ getHeaders()

const std::vector< std::pair< std::string, std::string > > & alexaClientSDK::avsCommon::avs::MessageRequest::getHeaders ( ) const

Get additional HTTP headers for this request

Returns
key/value pairs of extra HTTP headers to use with this request.

◆ getIsSerialized()

bool alexaClientSDK::avsCommon::avs::MessageRequest::getIsSerialized ( ) const

Return true if sending this message must be serialized with sending other serialized messages.

Returns
True if sending this message must be serialized with sending other serialized messages.

◆ getJsonContent()

std::string alexaClientSDK::avsCommon::avs::MessageRequest::getJsonContent ( ) const

Retrieves the JSON content to be sent to AVS.

Returns
The JSON content to be sent to AVS.

◆ getUriPathExtension()

std::string alexaClientSDK::avsCommon::avs::MessageRequest::getUriPathExtension ( ) const

Retrieves the path extension to be appended to the base URL when sending.

Returns
The path extension to be appended to the base URL when sending.

◆ removeObserver()

void alexaClientSDK::avsCommon::avs::MessageRequest::removeObserver ( std::shared_ptr< avsCommon::sdkInterfaces::MessageRequestObserverInterface observer)

Remove observer of MessageRequestObserverInterface.

Parameters
observerThe observer to be removed from the set.

◆ sendCompleted()

void alexaClientSDK::avsCommon::avs::MessageRequest::sendCompleted ( avsCommon::sdkInterfaces::MessageRequestObserverInterface::Status  status)
virtual

This is called once the send request has completed. The status parameter indicates success or failure.

Parameters
statusWhether the send request succeeded or failed.

Reimplemented in alexaClientSDK::capabilityAgents::playbackController::PlaybackMessageRequest, alexaClientSDK::capabilityAgents::doNotDisturb::DNDMessageRequest, alexaClientSDK::integration::ObservableMessageRequest, and alexaClientSDK::avsCommon::avs::WaitableMessageRequest.

Member Data Documentation

◆ m_headers

std::vector<std::pair<std::string, std::string> > alexaClientSDK::avsCommon::avs::MessageRequest::m_headers
protected

Optional headers to send with this request to AVS.

◆ m_isSerialized

bool alexaClientSDK::avsCommon::avs::MessageRequest::m_isSerialized
protected

True if sending this message must be serialized with sending other serialized messages.

◆ m_jsonContent

std::string alexaClientSDK::avsCommon::avs::MessageRequest::m_jsonContent
protected

The JSON content to be sent to AVS.

◆ m_observerMutex

std::mutex alexaClientSDK::avsCommon::avs::MessageRequest::m_observerMutex
protected

Mutex to guard access of m_observers.

◆ m_observers

std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::MessageRequestObserverInterface> > alexaClientSDK::avsCommon::avs::MessageRequest::m_observers
protected

Set of observers of MessageRequestObserverInterface.

◆ m_readers

std::vector<std::shared_ptr<NamedReader> > alexaClientSDK::avsCommon::avs::MessageRequest::m_readers
protected

The AttachmentReaders of the Attachments data to be sent to AVS.

◆ m_uriPathExtension

std::string alexaClientSDK::avsCommon::avs::MessageRequest::m_uriPathExtension
protected

The path extension to be appended to the base URL when sending.


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

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