AlexaClientSDK  1.25.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_
bool isEnabled()
Definition: TestMessageSender.cpp:69
void addConnectionStatusObserver(std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface > observer)
Definition: TestMessageSender.cpp:81
void doShutdown() override
Definition: TestMessageSender.cpp:96
SendParams waitForNext(const std::chrono::seconds duration)
Definition: TestMessageSender.cpp:49
std::shared_ptr< avsCommon::avs::MessageRequest > request
Definition: TestMessageSender.h:52
void enable()
Definition: TestMessageSender.cpp:61
void removeMessageObserver(std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > observer)
Definition: TestMessageSender.cpp:100
void setAVSGateway(const std::string &avsGateway)
Definition: TestMessageSender.cpp:77
void addMessageObserver(std::shared_ptr< avsCommon::sdkInterfaces::MessageObserverInterface > observer)
Definition: TestMessageSender.cpp:91
void removeConnectionStatusObserver(std::shared_ptr< avsCommon::sdkInterfaces::ConnectionStatusObserverInterface > observer)
Definition: TestMessageSender.cpp:86
void sendMessage(std::shared_ptr< avsCommon::avs::MessageRequest > request) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void disable()
Definition: TestMessageSender.cpp:65
This specifies an interface to send a message.
Definition: MessageSenderInterface.h:26
void reconnect()
Definition: TestMessageSender.cpp:73
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
std::shared_ptr< acl::AVSConnectionManager > getConnectionManager() const
Definition: TestMessageSender.cpp:105

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