AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MessageInterface.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_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_MESSAGES_MESSAGEINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_MESSAGES_MESSAGEINTERFACE_H_
18 
19 #include <string>
20 
21 #include <rapidjson/document.h>
22 #include <rapidjson/writer.h>
23 #include <rapidjson/stringbuffer.h>
24 
25 namespace alexaClientSDK {
26 namespace sampleApplications {
27 namespace ipcServerSampleApp {
28 namespace messages {
29 
31 const char MSG_HEADER_TAG[] = "header";
32 
34 const char MSG_PAYLOAD_TAG[] = "payload";
35 
37 const char MSG_VERSION_TAG[] = "version";
38 
40 const char MSG_NAMESPACE_TAG[] = "namespace";
41 
43 const char MSG_NAME_TAG[] = "name";
44 
55 protected:
56  rapidjson::Document mDocument;
58 
59 public:
66  MessageInterface(const int version, const std::string& nameSpace, const std::string& name) :
67  mDocument(rapidjson::kObjectType),
68  mPayload(rapidjson::kObjectType) {
69  auto& alloc = mDocument.GetAllocator();
70 
71  rapidjson::Value header(rapidjson::kObjectType);
72  header.AddMember(MSG_VERSION_TAG, version, alloc);
73  header.AddMember(MSG_NAMESPACE_TAG, nameSpace, alloc);
74  header.AddMember(MSG_NAME_TAG, name, alloc);
75  mDocument.AddMember(MSG_HEADER_TAG, header, alloc);
76  }
77 
82  virtual std::string get() = 0;
83 
88  virtual rapidjson::Value&& getValue() = 0;
89 };
90 } // namespace messages
91 } // namespace ipcServerSampleApp
92 } // namespace sampleApplications
93 } // namespace alexaClientSDK
94 
95 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_MESSAGES_MESSAGEINTERFACE_H_
const char MSG_PAYLOAD_TAG[]
The payload json key in the message.
Definition: MessageInterface.h:34
::std::string string
Definition: gtest-port.h:1097
const char MSG_VERSION_TAG[]
The version json key in the message.
Definition: MessageInterface.h:37
const char MSG_NAME_TAG[]
The name json key in the message.
Definition: MessageInterface.h:43
MessageInterface(const int version, const std::string &nameSpace, const std::string &name)
Definition: MessageInterface.h:66
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
rapidjson::Document mDocument
Definition: MessageInterface.h:56
const char MSG_HEADER_TAG[]
The namespace json key in the message.
Definition: MessageInterface.h:31
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
const char MSG_NAMESPACE_TAG[]
The namespace json key in the message.
Definition: MessageInterface.h:40

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