AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MessageRequestHandler.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_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEREQUESTHANDLER_H_
17 #define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEREQUESTHANDLER_H_
18 
19 #include <memory>
20 
28 
32 
33 namespace alexaClientSDK {
34 namespace acl {
35 
40  : public ExchangeHandler
43  , public std::enable_shared_from_this<MessageRequestHandler> {
44 public:
48  ~MessageRequestHandler() override;
49 
63  static std::shared_ptr<MessageRequestHandler> create(
64  std::shared_ptr<ExchangeHandlerContextInterface> context,
65  const std::string& authToken,
66  std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest,
67  std::shared_ptr<MessageConsumerInterface> messageConsumer,
68  std::shared_ptr<avsCommon::avs::attachment::AttachmentManagerInterface> attachmentManager,
69  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
70  std::shared_ptr<avsCommon::sdkInterfaces::EventTracerInterface> eventTracer = nullptr,
71  const std::shared_ptr<avsCommon::utils::power::PowerResource>& powerResource = nullptr);
72 
76  std::vector<std::string> getRequestHeaderLines() override;
77  avsCommon::utils::http2::HTTP2SendDataResult onSendMimePartData(char* bytes, size_t size) override;
79 
82  void onActivity() override;
83  bool onReceiveResponseCode(long responseCode) override;
85  override;
87 private:
98  std::shared_ptr<ExchangeHandlerContextInterface> context,
99  const std::string& authToken,
100  std::shared_ptr<avsCommon::avs::MessageRequest> messageRequest,
101  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
102  const std::shared_ptr<avsCommon::utils::power::PowerResource>& powerResource);
103 
107  void reportMessageRequestAcknowledged();
108 
112  void reportMessageRequestFinished();
113 
118  void recordStreamMetric(std::size_t bytes);
119 
123  void recordStartOfEventMetric();
124 
126  std::shared_ptr<avsCommon::avs::MessageRequest> m_messageRequest;
127 
129  std::string m_json;
130 
132  const char* m_jsonNext;
133 
135  size_t m_countOfJsonBytesLeft;
136 
138  size_t m_countOfPartsSent;
139 
141  std::shared_ptr<avsCommon::avs::MessageRequest::NamedReader> m_namedReader;
142 
144  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
145 
147  bool m_wasMessageRequestAcknowledgeReported;
148 
150  bool m_wasMessageRequestFinishedReported;
151 
153  long m_responseCode;
154 
156  std::shared_ptr<avsCommon::utils::power::PowerResource> m_powerResource;
157 
160 
162  std::size_t m_streamBytesRead;
163 
165  bool m_recordedStreamMetric;
166 };
167 
168 } // namespace acl
169 } // namespace alexaClientSDK
170 
171 #endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_MESSAGEREQUESTHANDLER_H_
::std::string string
Definition: gtest-port.h:1097
static std::shared_ptr< MessageRequestHandler > create(std::shared_ptr< ExchangeHandlerContextInterface > context, const std::string &authToken, std::shared_ptr< avsCommon::avs::MessageRequest > messageRequest, std::shared_ptr< MessageConsumerInterface > messageConsumer, std::shared_ptr< avsCommon::avs::attachment::AttachmentManagerInterface > attachmentManager, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder, std::shared_ptr< avsCommon::sdkInterfaces::EventTracerInterface > eventTracer=nullptr, const std::shared_ptr< avsCommon::utils::power::PowerResource > &powerResource=nullptr)
Definition: HTTP2MimeRequestSourceInterface.h:35
std::vector< std::string > getRequestHeaderLines() override
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
HTTP2ResponseFinishedStatus
Definition: HTTP2ResponseFinishedStatus.h:29
Definition: ExchangeHandler.h:31
avsCommon::utils::http2::HTTP2GetMimeHeadersResult getMimePartHeaderLines() override
Definition: MessageRequestHandler.h:39
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
Definition: MimeResponseStatusHandlerInterface.h:29
Status
Definition: MessageRequestObserverInterface.h:33
avsCommon::utils::http2::HTTP2SendDataResult onSendMimePartData(char *bytes, size_t size) override
void onResponseFinished(avsCommon::utils::http2::HTTP2ResponseFinishedStatus status, const std::string &nonMimeBody) override
bool onReceiveResponseCode(long responseCode) override

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