Alexa Auto SDK  2.3.1
AlexaClient.h
1 /*
2  * Copyright 2017-2020 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 AACE_ALEXA_ALEXA_CLIENT_H
17 #define AACE_ALEXA_ALEXA_CLIENT_H
18 
19 #include "AACE/Core/PlatformInterface.h"
20 #include "AlexaEngineInterfaces.h"
21 
24 namespace aace {
25 namespace alexa {
26 
31 protected:
32  AlexaClient() = default;
33 
34 public:
35  virtual ~AlexaClient();
36 
40  enum class DialogState {
41 
45  IDLE,
46 
50  LISTENING,
51 
55  EXPECTING,
56 
61  THINKING,
62 
66  SPEAKING
67  };
68 
78  virtual void dialogStateChanged(DialogState state) {
79  }
80 
83 
90  virtual void authStateChanged(AuthState state, AuthError error) {
91  }
92 
96  enum class ConnectionStatus {
97 
101  DISCONNECTED,
102 
106  PENDING,
107 
111  CONNECTED
112  };
113 
118 
122  NONE,
123 
127  SUCCESS,
128 
132  UNRECOVERABLE_ERROR,
133 
137  ACL_CLIENT_REQUEST,
138 
142  ACL_DISABLED,
143 
147  DNS_TIMEDOUT,
148 
152  CONNECTION_TIMEDOUT,
153 
157  CONNECTION_THROTTLED,
158 
162  INVALID_AUTH,
163 
167  PING_TIMEDOUT,
168 
172  WRITE_TIMEDOUT,
173 
177  READ_TIMEDOUT,
178 
182  FAILURE_PROTOCOL_ERROR,
183 
187  INTERNAL_ERROR,
188 
192  SERVER_INTERNAL_ERROR,
193 
197  SERVER_SIDE_DISCONNECT,
198 
202  SERVER_ENDPOINT_CHANGED
203  };
204 
212  }
213 
219  void stopForegroundActivity();
220 
227  void setEngineInterface(std::shared_ptr<aace::alexa::AlexaClientEngineInterface> alexaClientEngineInterface);
228 
229 private:
230  std::weak_ptr<aace::alexa::AlexaClientEngineInterface> m_alexaClientEngineInterface;
231 };
232 
233 inline std::ostream& operator<<(std::ostream& stream, const AlexaClient::DialogState& state) {
234  switch (state) {
236  stream << "IDLE";
237  break;
239  stream << "LISTENING";
240  break;
242  stream << "EXPECTING";
243  break;
245  stream << "THINKING";
246  break;
248  stream << "SPEAKING";
249  break;
250  }
251  return stream;
252 }
253 
254 inline std::ostream& operator<<(std::ostream& stream, const AlexaClient::ConnectionStatus& status) {
255  switch (status) {
257  stream << "DISCONNECTED";
258  break;
260  stream << "PENDING";
261  break;
263  stream << "CONNECTED";
264  break;
265  }
266  return stream;
267 }
268 
269 inline std::ostream& operator<<(std::ostream& stream, const AlexaClient::ConnectionChangedReason& reason) {
270  switch (reason) {
272  stream << "NONE";
273  break;
275  stream << "SUCCESS";
276  break;
278  stream << "UNRECOVERABLE_ERROR";
279  break;
281  stream << "ACL_CLIENT_REQUEST";
282  break;
284  stream << "ACL_DISABLED";
285  break;
287  stream << "DNS_TIMEDOUT";
288  break;
290  stream << "CONNECTION_TIMEDOUT";
291  break;
293  stream << "CONNECTION_THROTTLED";
294  break;
296  stream << "INVALID_AUTH";
297  break;
299  stream << "PING_TIMEDOUT";
300  break;
302  stream << "WRITE_TIMEDOUT";
303  break;
305  stream << "READ_TIMEDOUT";
306  break;
308  stream << "FAILURE_PROTOCOL_ERROR";
309  break;
311  stream << "INTERNAL_ERROR";
312  break;
314  stream << "SERVER_INTERNAL_ERROR";
315  break;
317  stream << "SERVER_SIDE_DISCONNECT";
318  break;
320  stream << "SERVER_ENDPOINT_CHANGED";
321  break;
322  }
323  return stream;
324 }
325 
326 } // namespace alexa
327 } // namespace aace
328 
329 #endif // AACE_ALEXA_ALEXA_CLIENT_H
ConnectionStatus
Definition: AlexaClient.h:96
AuthState
Definition: AlexaEngineInterfaces.h:205
Definition: PlatformInterface.h:29
AuthError
Definition: AlexaEngineInterfaces.h:231
DialogState
Definition: AlexaClient.h:40
Definition: AddressBook.h:26
Definition: AlexaClient.h:30
virtual void dialogStateChanged(DialogState state)
Definition: AlexaClient.h:78
virtual void connectionStatusChanged(ConnectionStatus status, ConnectionChangedReason reason)
Definition: AlexaClient.h:211
virtual void authStateChanged(AuthState state, AuthError error)
Definition: AlexaClient.h:90
ConnectionChangedReason
Definition: AlexaClient.h:117
void stopForegroundActivity()
Definition: AlexaClient.cpp:28

Alexa Auto SDK 2.3.1 - Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0