AlexaClientSDK  1.23.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
ContextRequesterInterface.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 
19 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_CONTEXTREQUESTERINTERFACE_H_
20 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_CONTEXTREQUESTERINTERFACE_H_
21 
22 #include <cstdint>
23 #include <string>
24 #include <ostream>
25 
29 
32 
33 namespace alexaClientSDK {
34 namespace avsCommon {
35 namespace sdkInterfaces {
36 
40 enum class ContextRequestError {
43 
46 
49 };
50 
55 public:
59  virtual ~ContextRequesterInterface() = default;
60 
71  virtual void onContextAvailable(const std::string& jsonContext);
72 
85  virtual void onContextAvailable(
86  const endpoints::EndpointIdentifier& endpointId,
87  const avs::AVSContext& endpointContext,
88  ContextRequestToken requestToken);
89 
100  virtual void onContextFailure(const ContextRequestError error);
101 
112  virtual void onContextFailure(const ContextRequestError error, ContextRequestToken token);
113 };
114 
122 inline std::ostream& operator<<(std::ostream& stream, const ContextRequestError& error) {
123  switch (error) {
125  stream << "STATE_PROVIDER_TIMEDOUT";
126  break;
128  stream << "BUILD_CONTEXT_ERROR";
129  break;
131  stream << "ENDPOINT_UNREACHABLE";
132  break;
133  }
134  return stream;
135 }
136 
137 inline void ContextRequesterInterface::onContextAvailable(const std::string& jsonContext) {
139  utils::logger::LogEntry("ContextRequesterInterface", __func__).d("reason", "methodDeprecated"));
140 }
141 
143  const endpoints::EndpointIdentifier& endpointId,
144  const avs::AVSContext& endpointContext,
145  ContextRequestToken requestToken) {
146  onContextAvailable(endpointContext.toJson());
147 }
148 
151  utils::logger::LogEntry("ContextRequesterInterface", __func__).d("reason", "methodDeprecated"));
152 }
153 
155  onContextFailure(error);
156 }
157 
158 } // namespace sdkInterfaces
159 } // namespace avsCommon
160 } // namespace alexaClientSDK
161 
162 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_CONTEXTREQUESTERINTERFACE_H_
std::string toJson() const
Definition: AVSContext.cpp:68
std::ostream & operator<<(std::ostream &stream, const AudioInputProcessorObserverInterface::State &state)
Definition: AudioInputProcessorObserverInterface.h:86
ContextRequestError
Definition: ContextRequesterInterface.h:40
unsigned int ContextRequestToken
Alias for the token used to identify a context request.
Definition: ContextRequestToken.h:23
virtual void onContextAvailable(const std::string &jsonContext)
Definition: ContextRequesterInterface.h:137
getContext request failed due to an error building the context.
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
virtual void onContextFailure(const ContextRequestError error)
Definition: ContextRequesterInterface.h:149
getContext request failed due to an error while trying to reach out to the endpoint.
void acsdkError(const LogEntry &entry)
Definition: LoggerUtils.cpp:80
std::string EndpointIdentifier
Definition: EndpointIdentifier.h:38
getContext request failed due to a timeout on one or more stateProviderInterfaces.
LogEntry is used to compile the log entry text to log via Logger.
Definition: LogEntry.h:32

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