Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Version 1.20.0 alexa-client-sdk
Browse files Browse the repository at this point in the history
Changes in this update:

Feature enhancements, updates, and resolved issues from all releases are available on the [Amazon developer portal](https://developer.amazon.com/docs/alexa/avs-device-sdk/release-notes.html).
  • Loading branch information
alexandrekm-amzn committed Jun 22, 2020
1 parent 7da524a commit f82767c
Show file tree
Hide file tree
Showing 466 changed files with 21,797 additions and 5,140 deletions.
5 changes: 3 additions & 2 deletions ACL/include/ACL/Transport/ExchangeHandlerContextInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <memory>
#include <string>

#include <AVSCommon/AVS/MessageRequest.h>
#include <AVSCommon/Utils/HTTP2/HTTP2RequestConfig.h>
#include <AVSCommon/Utils/HTTP2/HTTP2RequestInterface.h>

Expand Down Expand Up @@ -48,7 +49,7 @@ class ExchangeHandlerContextInterface {
/**
* Notification that an @c MessageRequest has been sent.
*/
virtual void onMessageRequestSent() = 0;
virtual void onMessageRequestSent(const std::shared_ptr<avsCommon::avs::MessageRequest>& request) = 0;

/**
* Notification that sending a message request timed out.
Expand All @@ -59,7 +60,7 @@ class ExchangeHandlerContextInterface {
* Notification that sending a @c MessageRequest has failed or been acknowledged by AVS
* (this is used to indicate it is okay to send the next message).
*/
virtual void onMessageRequestAcknowledged() = 0;
virtual void onMessageRequestAcknowledged(const std::shared_ptr<avsCommon::avs::MessageRequest>& request) = 0;

/**
* Notification tht a message request has finished it's exchange with AVS.
Expand Down
13 changes: 7 additions & 6 deletions ACL/include/ACL/Transport/HTTP2Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <AVSCommon/AVS/Attachment/AttachmentManager.h>
#include <AVSCommon/SDKInterfaces/AuthDelegateInterface.h>
#include <AVSCommon/SDKInterfaces/EventTracerInterface.h>
#include <AVSCommon/SDKInterfaces/PostConnectSendMessageInterface.h>
#include <AVSCommon/SDKInterfaces/MessageSenderInterface.h>
#include <AVSCommon/Utils/HTTP2/HTTP2ConnectionInterface.h>
#include <AVSCommon/Utils/HTTP2/HTTP2ConnectionObserverInterface.h>
#include <AVSCommon/Utils/Metrics/MetricRecorderInterface.h>
Expand All @@ -51,7 +51,7 @@ class HTTP2Transport
: public std::enable_shared_from_this<HTTP2Transport>
, public TransportInterface
, public PostConnectObserverInterface
, public avsCommon::sdkInterfaces::PostConnectSendMessageInterface
, public avsCommon::sdkInterfaces::MessageSenderInterface
, public avsCommon::sdkInterfaces::AuthObserverInterface
, public avsCommon::utils::http2::HTTP2ConnectionObserverInterface
, public ExchangeHandlerContextInterface {
Expand Down Expand Up @@ -129,9 +129,10 @@ class HTTP2Transport
void onWakeVerifyConnectivity() override;
/// @}

/// @name PostConnectSendMessageInterface methods.
/// HTTP2Transport uses sendMessage to handle the post-connect state only.
/// @name MessageSenderInterface methods.
/// @{
void sendPostConnectMessage(std::shared_ptr<avsCommon::avs::MessageRequest> request) override;
void sendMessage(std::shared_ptr<avsCommon::avs::MessageRequest> request) override;
/// @}

/// @name PostConnectObserverInterface methods.
Expand All @@ -156,9 +157,9 @@ class HTTP2Transport
/// @{
void onDownchannelConnected() override;
void onDownchannelFinished() override;
void onMessageRequestSent() override;
void onMessageRequestSent(const std::shared_ptr<avsCommon::avs::MessageRequest>& request) override;
void onMessageRequestTimeout() override;
void onMessageRequestAcknowledged() override;
void onMessageRequestAcknowledged(const std::shared_ptr<avsCommon::avs::MessageRequest>& request) override;
void onMessageRequestFinished() override;
void onPingRequestAcknowledged(bool success) override;
void onPingTimeout() override;
Expand Down
29 changes: 14 additions & 15 deletions ACL/include/ACL/Transport/MessageRequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ class MessageRequestHandler
std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer = nullptr);

/// @name HTTP2MimeRequestSourceInterface methods
/// @{
avsCommon::utils::http2::HTTP2GetMimeHeadersResult getMimePartHeaderLines() override;
std::vector<std::string> getRequestHeaderLines() override;
avsCommon::utils::http2::HTTP2SendDataResult onSendMimePartData(char* bytes, size_t size) override;
/// @}

/// @name MimeResponseStatusHandlerInterface
/// @{
void onActivity() override;
bool onReceiveResponseCode(long responseCode) override;
void onResponseFinished(avsCommon::utils::http2::HTTP2ResponseFinishedStatus status, const std::string& nonMimeBody)
override;
/// @}
private:
/**
* Constructor.
Expand All @@ -91,21 +105,6 @@ class MessageRequestHandler
*/
void reportMessageRequestFinished();

/// @name HTTP2MimeRequestSourceInterface methods
/// @{
std::vector<std::string> getRequestHeaderLines() override;
avsCommon::utils::http2::HTTP2GetMimeHeadersResult getMimePartHeaderLines() override;
avsCommon::utils::http2::HTTP2SendDataResult onSendMimePartData(char* bytes, size_t size) override;
/// @}

/// @name MimeResponseStatusHandlerInterface
/// @{
void onActivity() override;
bool onReceiveResponseCode(long responseCode) override;
void onResponseFinished(avsCommon::utils::http2::HTTP2ResponseFinishedStatus status, const std::string& nonMimeBody)
override;
/// @}

/// The MessageRequest that this handler is servicing.
std::shared_ptr<avsCommon::avs::MessageRequest> m_messageRequest;

Expand Down
37 changes: 10 additions & 27 deletions ACL/include/ACL/Transport/MessageRequestQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,32 @@ namespace acl {
*/
class MessageRequestQueue : public MessageRequestQueueInterface {
public:
/// Helper structure to keep track of the SendQueue.
struct MessageRequestQueueStruct {
/// Indicates if the queue is waiting on a response.
bool isQueueWaitingForResponse;

/// The queue used to send @c MessageRequest.
std::deque<std::pair<
std::chrono::time_point<std::chrono::steady_clock>,
std::shared_ptr<avsCommon::avs::MessageRequest>>>
queue;

MessageRequestQueueStruct() : isQueueWaitingForResponse{false} {
}
};

/**
* Constructor.
*/
MessageRequestQueue();

/**
* Destructor.
*/
~MessageRequestQueue() override;

/// Override MessageRequestQueueInterface methods
/// @{
void enqueueRequest(std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest) override;
avsCommon::utils::Optional<std::chrono::time_point<std::chrono::steady_clock>> peekRequestTime() override;
std::shared_ptr<avsCommon::avs::MessageRequest> dequeueRequest() override;
std::shared_ptr<avsCommon::avs::MessageRequest> dequeueOldestRequest() override;
std::shared_ptr<avsCommon::avs::MessageRequest> dequeueSendableRequest() override;
bool isMessageRequestAvailable() const override;
void setWaitingFlagForQueue() override;
void clearWaitingFlagForQueue() override;
void setWaitingForSendAcknowledgement() override;
void clearWaitingForSendAcknowledgement() override;
bool empty() const override;
void clear() override;
/// @}

private:
/// Member to keep track of the current @c MessageRequests present.
int m_size;
/// Flag indicating whether to block sending serialized messages.
bool m_isWaitingForAcknowledgement;

/// The struct that contains the message queue
MessageRequestQueueStruct m_sendQueue;
/// The queue of @c MessageRequests to be sent, paired with the time that each request was added to the queue.
std::deque<
std::pair<std::chrono::time_point<std::chrono::steady_clock>, std::shared_ptr<avsCommon::avs::MessageRequest>>>
m_queue;
};

} // namespace acl
Expand Down
41 changes: 21 additions & 20 deletions ACL/include/ACL/Transport/MessageRequestQueueInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ namespace alexaClientSDK {
namespace acl {

/**
* An interface that abstracts the operations of a @c MessageRequestQueuesMap between the standard version
* and the synchronized implementation.
* An interface that abstracts queueing @c MessageRequests.
*/
class MessageRequestQueueInterface {
public:
Expand All @@ -39,8 +38,7 @@ class MessageRequestQueueInterface {
virtual ~MessageRequestQueueInterface() = default;

/**
* Enqueues the @c MessageRequest to the corresponding send queue based on the send queue type.
* If send queue type is not present, a new queue is created before enqueuing the request.
* Enqueues a @c MessageRequest.
*/
virtual void enqueueRequest(std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest) = 0;

Expand All @@ -52,14 +50,21 @@ class MessageRequestQueueInterface {
virtual avsCommon::utils::Optional<std::chrono::time_point<std::chrono::steady_clock>> peekRequestTime() = 0;

/**
* Dequeues the next available @c MessageRequest by taking into account if the queue is waiting for
* a response. This method keeps track of the queue being processed and once a request from the queue
* is dequeued moves it to the next queue. It also loops back to the starting queue at the end and exits
* the loop if a valid MessageRequest is found or if it reaches the place it started.
* Dequeues the oldest @c MessageRequest regardless of whether or not the queue is waiting for
* a response.
*
* @return @c MessageRequest if an available, else return nullptr.
* @return @c MessageRequest if available, else return nullptr.
*/
virtual std::shared_ptr<avsCommon::avs::MessageRequest> dequeueRequest() = 0;
virtual std::shared_ptr<avsCommon::avs::MessageRequest> dequeueOldestRequest() = 0;

/**
* Dequeues the next available @c MessageRequest taking into account if the queue is waiting for
* a response to a previously sent message and if any messages that do not care about sequencing
* are in the queue.
*
* @return @c MessageRequest if available, else return nullptr.
*/
virtual std::shared_ptr<avsCommon::avs::MessageRequest> dequeueSendableRequest() = 0;

/**
* This method checks if there is a @c MessageRequest available to be sent.
Expand All @@ -69,28 +74,24 @@ class MessageRequestQueueInterface {
virtual bool isMessageRequestAvailable() const = 0;

/**
* Sets the waiting flag for the queue specified by the given send queue type.
*
* @param sendQueueType the send queue type of the queue to set the waiting flag on.
* Sets the flag indicating that the queue is waiting for a send to be acknowledged.
*/
virtual void setWaitingFlagForQueue() = 0;
virtual void setWaitingForSendAcknowledgement() = 0;

/**
* Clear the waiting flag for the queue specified by the given send queue type.
*
* @param sendQueueType the send queue type of the queue to clear the waiting flag on.
* Clear the flag indicating that the queue is waiting for a send to be acknowledged.
*/
virtual void clearWaitingFlagForQueue() = 0;
virtual void clearWaitingForSendAcknowledgement() = 0;

/**
* Checks if there are any @c MessageRequests.
* Checks if there are any queued @c MessageRequests.
*
* @return true if there are no messageRequests in the queue, else false.
*/
virtual bool empty() const = 0;

/**
* Clears all the @c MessageRequests along with the corresponding queues.
* Clears all queue of @c MessageRequests.
*/
virtual void clear() = 0;
};
Expand Down
51 changes: 51 additions & 0 deletions ACL/include/ACL/Transport/MessageRouterFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

#ifndef ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEROUTERFACTORY_H_
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEROUTERFACTORY_H_

#include "ACL/Transport/MessageRouter.h"
#include "ACL/Transport/MessageRouterFactoryInterface.h"

namespace alexaClientSDK {
namespace acl {

using namespace alexaClientSDK::acl;
using namespace avsCommon::sdkInterfaces;
using namespace avsCommon::avs::attachment;

/**
* Factory for creating MessageRouter instances that manages connection over some medium to AVS.
*/
class MessageRouterFactory : public MessageRouterFactoryInterface {
public:
/**
* Default constructor
*/
MessageRouterFactory();

/// @name MessageRouterFactoryInterface methods.
/// @{
std::shared_ptr<MessageRouterInterface> createMessageRouter(
std::shared_ptr<AuthDelegateInterface> authDelegate,
std::shared_ptr<AttachmentManager> attachmentManager,
std::shared_ptr<TransportFactoryInterface> transportFactory) override;
/// @}
};

} // namespace acl
} // namespace alexaClientSDK

#endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEROUTERFACTORY_H_
57 changes: 57 additions & 0 deletions ACL/include/ACL/Transport/MessageRouterFactoryInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

#ifndef ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEROUTERFACTORYINTERFACE_H_
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEROUTERFACTORYINTERFACE_H_

#include "ACL/Transport/MessageRouterInterface.h"
#include "ACL/Transport/TransportFactoryInterface.h"

namespace alexaClientSDK {
namespace acl {

using namespace alexaClientSDK::acl;
using namespace avsCommon::sdkInterfaces;
using namespace avsCommon::avs::attachment;

/**
* Interface for creating instances of @c MessageRouterInterface
*/
class MessageRouterFactoryInterface {
public:
/**
* Destructor.
*/
virtual ~MessageRouterFactoryInterface() = default;

/**
* Create a MessageRouter.
*
* @param authDelegate An implementation of an AuthDelegate, which will provide valid access tokens with which
* the MessageRouter can authorize the client to AVS.
* @param attachmentManager The AttachmentManager, which allows ACL to write attachments received from AVS.
* @param transportFactory Factory used to create new instances of @c TransportInterface.
* @return A new MessageRouter object
*/
virtual std::shared_ptr<MessageRouterInterface> createMessageRouter(
std::shared_ptr<AuthDelegateInterface> authDelegate,
std::shared_ptr<AttachmentManager> attachmentManager,
std::shared_ptr<TransportFactoryInterface> transportFactory) = 0;
};

} // namespace acl
} // namespace alexaClientSDK

#endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEROUTERFACTORYINTERFACE_H_
4 changes: 0 additions & 4 deletions ACL/include/ACL/Transport/MessageRouterObserverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class MessageRouterObserverInterface {
*/
virtual ~MessageRouterObserverInterface() = default;

private:
/**
* This function will be called when the connection status changes.
*
Expand All @@ -53,9 +52,6 @@ class MessageRouterObserverInterface {
* @param message The AVS message that has been received.
*/
virtual void receive(const std::string& contextId, const std::string& message) = 0;

/// The friend declaration.
friend class MessageRouter;
};

} // namespace acl
Expand Down

0 comments on commit f82767c

Please sign in to comment.