AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
TestMessageSender.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTMESSAGESENDER_H_
17 #define ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTMESSAGESENDER_H_
18 
19 #include <string>
20 #include <chrono>
21 #include <deque>
22 #include <mutex>
23 
28 
29 namespace alexaClientSDK {
30 namespace integration {
31 namespace test {
32 
36 public:
38  ~TestMessageSender() = default;
39 
40  void sendMessage(std::shared_ptr<avsCommon::avs::MessageRequest> request) override;
41 
43  std::shared_ptr<acl::MessageRouterInterface> messageRouter,
44  bool isEnabled,
45  std::shared_ptr<avsCommon::sdkInterfaces::ConnectionStatusObserverInterface> connectionStatusObserver,
46  std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> messageObserver);
47 
48  class SendParams {
49  public:
50  enum class Type { SEND, TIMEOUT };
52  std::shared_ptr<avsCommon::avs::MessageRequest> request;
53  };
54 
55  SendParams waitForNext(const std::chrono::seconds duration);
56 
61  void enable();
62 
68  void disable();
69 
75  bool isEnabled();
76 
84  void reconnect();
85 
91  void setAVSGateway(const std::string& avsGateway);
92 
94  std::shared_ptr<avsCommon::sdkInterfaces::ConnectionStatusObserverInterface> observer);
95 
102  std::shared_ptr<avsCommon::sdkInterfaces::ConnectionStatusObserverInterface> observer);
103 
109  void addMessageObserver(std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> observer);
110 
116  void removeMessageObserver(std::shared_ptr<avsCommon::sdkInterfaces::MessageObserverInterface> observer);
117 
118  void doShutdown() override;
119 
120  std::shared_ptr<acl::AVSConnectionManager> getConnectionManager() const;
121 
122 private:
124  std::mutex m_mutex;
126  std::condition_variable m_wakeTrigger;
128  std::deque<SendParams> m_queue;
129 
130  std::shared_ptr<acl::AVSConnectionManager> m_connectionManager;
131 };
132 
133 } // namespace test
134 } // namespace integration
135 } // namespace alexaClientSDK
136 
137 #endif // ALEXA_CLIENT_SDK_INTEGRATION_INCLUDE_INTEGRATION_TESTMESSAGESENDER_H_
alexaClientSDK::avsCommon::utils::RequiresShutdown
Definition: RequiresShutdown.h:32
alexaClientSDK::integration::test::TestMessageSender::isEnabled
bool isEnabled()
Definition: TestMessageSender.cpp:69
alexaClientSDK::integration::test::TestMessageSender::addConnectionStatusObserver
void addConnectionStatusObserver(std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface > observer)
Definition: TestMessageSender.cpp:81
alexaClientSDK::integration::test::TestMessageSender
Definition: TestMessageSender.h:33
alexaClientSDK::integration::test::TestMessageSender::waitForNext
SendParams waitForNext(const std::chrono::seconds duration)
Definition: TestMessageSender.cpp:49
alexaClientSDK::integration::test::TestMessageSender::~TestMessageSender
~TestMessageSender()=default
Destructor.
alexaClientSDK::integration::test::TestMessageSender::enable
void enable()
Definition: TestMessageSender.cpp:61
alexaClientSDK::integration::test::TestMessageSender::doShutdown
void doShutdown() override
Definition: TestMessageSender.cpp:96
test
Definition: AmdMetricWrapperTest.cpp:24
alexaClientSDK::integration::test::TestMessageSender::SendParams
Definition: TestMessageSender.h:48
alexaClientSDK::integration::test::TestMessageSender::SendParams::request
std::shared_ptr< avsCommon::avs::MessageRequest > request
Definition: TestMessageSender.h:52
alexaClientSDK::integration::test::TestMessageSender::SendParams::Type
Type
Definition: TestMessageSender.h:50
alexaClientSDK::integration::test::TestMessageSender::setAVSGateway
void setAVSGateway(const std::string &avsGateway)
Definition: TestMessageSender.cpp:77
alexaClientSDK::integration::test::TestMessageSender::removeMessageObserver
void removeMessageObserver(std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > observer)
Definition: TestMessageSender.cpp:100
RequiresShutdown.h
alexaClientSDK::integration::test::TestMessageSender::addMessageObserver
void addMessageObserver(std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > observer)
Definition: TestMessageSender.cpp:91
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
MessageObserverInterface.h
alexaClientSDK::integration::test::TestMessageSender::sendMessage
void sendMessage(std::shared_ptr< avsCommon::avs::MessageRequest > request) override
alexaClientSDK::integration::test::TestMessageSender::SendParams::Type::TIMEOUT
@ TIMEOUT
alexaClientSDK::integration::test::TestMessageSender::SendParams::type
Type type
Definition: TestMessageSender.h:51
alexaClientSDK::integration::test::TestMessageSender::removeConnectionStatusObserver
void removeConnectionStatusObserver(std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface > observer)
Definition: TestMessageSender.cpp:86
MessageSenderInterface.h
alexaClientSDK::integration::test::TestMessageSender::disable
void disable()
Definition: TestMessageSender.cpp:65
alexaClientSDK::integration::test::TestMessageSender::reconnect
void reconnect()
Definition: TestMessageSender.cpp:73
alexaClientSDK::avsCommon::sdkInterfaces::MessageSenderInterface
This specifies an interface to send a message.
Definition: MessageSenderInterface.h:26
AVSConnectionManager.h
alexaClientSDK::integration::test::TestMessageSender::SendParams::Type::SEND
@ SEND
alexaClientSDK::integration::test::TestMessageSender::TestMessageSender
TestMessageSender(std::shared_ptr< acl::MessageRouterInterface > messageRouter, bool isEnabled, std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface > connectionStatusObserver, std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > messageObserver)
Definition: TestMessageSender.cpp:29
alexaClientSDK::integration::test::TestMessageSender::getConnectionManager
std::shared_ptr< acl::AVSConnectionManager > getConnectionManager() const
Definition: TestMessageSender.cpp:105

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