forked from alexa/avs-device-sdk
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from xmos/xmos_v1.13
xmos v1.13
- Loading branch information
Showing
911 changed files
with
116,401 additions
and
14,460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2018 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_DOWNCHANNELHANDLER_H_ | ||
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_DOWNCHANNELHANDLER_H_ | ||
|
||
#include <memory> | ||
|
||
#include <AVSCommon/AVS/Attachment/AttachmentManager.h> | ||
#include <AVSCommon/Utils/HTTP2/HTTP2RequestSourceInterface.h> | ||
|
||
#include "ACL/Transport/ExchangeHandler.h" | ||
#include "ACL/Transport/MessageConsumerInterface.h" | ||
#include "ACL/Transport/MimeResponseStatusHandlerInterface.h" | ||
|
||
namespace alexaClientSDK { | ||
namespace acl { | ||
|
||
class DownchannelHandler; | ||
|
||
/** | ||
* Handle the HTTP2 request and response that establishes and services the downchannel of an connection to AVS. | ||
*/ | ||
class DownchannelHandler | ||
: public ExchangeHandler | ||
, public avsCommon::utils::http2::HTTP2RequestSourceInterface | ||
, public MimeResponseStatusHandlerInterface | ||
, public std::enable_shared_from_this<DownchannelHandler> { | ||
public: | ||
/** | ||
* Create a DownchannelHandler, and send the downchannel request. | ||
* | ||
* @param context The ExchangeContext in which this MessageRequest handler will operate. | ||
* @param authToken The token to use to authorize the request. | ||
* @param messageConsumer Object to send decoded messages to. | ||
* @param attachmentManager Object with which to get attachments to write to. | ||
* @return The new DownchannelHandler or nullptr if the operation failed. | ||
*/ | ||
static std::shared_ptr<DownchannelHandler> create( | ||
std::shared_ptr<ExchangeHandlerContextInterface> context, | ||
const std::string& authToken, | ||
std::shared_ptr<MessageConsumerInterface> messageConsumer, | ||
std::shared_ptr<avsCommon::avs::attachment::AttachmentManager> attachmentManager); | ||
|
||
private: | ||
/** | ||
* Constructor. | ||
* | ||
* @param context The ExchangeContext in which this MessageRequest handler will operate. | ||
* @param authToken The token to use to authorize the request. | ||
*/ | ||
DownchannelHandler(std::shared_ptr<ExchangeHandlerContextInterface> context, const std::string& authToken); | ||
|
||
/// @name HTTP2RequestSourceInterface methods | ||
/// @{ | ||
std::vector<std::string> getRequestHeaderLines() override; | ||
avsCommon::utils::http2::HTTP2SendDataResult onSendData(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; | ||
/// @} | ||
}; | ||
|
||
} // namespace acl | ||
} // namespace alexaClientSDK | ||
|
||
#endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_DOWNCHANNELHANDLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2018 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_EXCHANGEHANDLER_H_ | ||
#define ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_EXCHANGEHANDLER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "ACL/Transport/ExchangeHandlerContextInterface.h" | ||
|
||
namespace alexaClientSDK { | ||
namespace acl { | ||
|
||
class HTTP2Transport; | ||
|
||
/** | ||
* Common base class for HTTP2 request / response exchanges with AVS. | ||
*/ | ||
class ExchangeHandler { | ||
public: | ||
/** | ||
* Constructor. | ||
* | ||
* @param context The context in which this HTTP2 request / reply exchange will be performed. | ||
* @param authToken The authorization token to send in the request. | ||
*/ | ||
ExchangeHandler(std::shared_ptr<ExchangeHandlerContextInterface> context, const std::string& authToken); | ||
|
||
/** | ||
* Destructor | ||
*/ | ||
virtual ~ExchangeHandler() = default; | ||
|
||
protected: | ||
/// The @c HTTP2Transport instance for which this exchange is to be performed. | ||
std::shared_ptr<ExchangeHandlerContextInterface> m_context; | ||
|
||
/// The auth token used to make the request. | ||
const std::string m_authToken; | ||
|
||
/// The AVS authorization header to send in the request. | ||
const std::string m_authHeader; | ||
}; | ||
|
||
} // namespace acl | ||
} // namespace alexaClientSDK | ||
|
||
#endif // ALEXA_CLIENT_SDK_ACL_INCLUDE_ACL_TRANSPORT_EXCHANGEHANDLER_H_ |
Oops, something went wrong.