AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
ConnectionStatusObserverInterface.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_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_CONNECTIONSTATUSOBSERVERINTERFACE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_CONNECTIONSTATUSOBSERVERINTERFACE_H_
18 
19 #include <iostream>
20 #include <vector>
21 
22 namespace alexaClientSDK {
23 namespace avsCommon {
24 namespace sdkInterfaces {
25 
26 static const int ENGINE_TYPE_ALEXA_VOICE_SERVICES = 1;
27 
32 public:
36  enum class Status {
39 
41  PENDING,
42 
44  CONNECTED
45  };
46 
50  enum class ChangedReason {
52  NONE,
53 
55  SUCCESS,
56 
58  UNRECOVERABLE_ERROR,
59 
61  ACL_CLIENT_REQUEST,
62 
64  ACL_DISABLED,
65 
67  DNS_TIMEDOUT,
68 
70  CONNECTION_TIMEDOUT,
71 
73  CONNECTION_THROTTLED,
74 
76  INVALID_AUTH,
77 
79  PING_TIMEDOUT,
80 
82  WRITE_TIMEDOUT,
83 
85  READ_TIMEDOUT,
86 
88  FAILURE_PROTOCOL_ERROR,
89 
91  INTERNAL_ERROR,
92 
95 
97  SERVER_SIDE_DISCONNECT,
98 
100  SERVER_ENDPOINT_CHANGED
101  };
102 
107  EngineConnectionStatus(const int connectEngineType, ChangedReason connectReason, Status connectStatus) :
108  engineType{connectEngineType},
109  reason{connectReason},
110  status{connectStatus} {
111  }
112  // The engine type
114  // Reason for connection state change
116  // State of connection
118  };
119 
123  virtual ~ConnectionStatusObserverInterface() = default;
124 
131  virtual void onConnectionStatusChanged(const Status status, const ChangedReason reason) = 0;
132 
142  const Status status,
143  const std::vector<EngineConnectionStatus>& engineStatuses){};
144 };
145 
153 inline std::ostream& operator<<(std::ostream& stream, ConnectionStatusObserverInterface::Status status) {
154  switch (status) {
156  stream << "DISCONNECTED";
157  break;
159  stream << "PENDING";
160  break;
162  stream << "CONNECTED";
163  break;
164  }
165  return stream;
166 }
167 
175 inline std::ostream& operator<<(std::ostream& stream, ConnectionStatusObserverInterface::ChangedReason reason) {
176  switch (reason) {
178  stream << "NONE";
179  break;
181  stream << "SUCCESS";
182  break;
184  stream << "UNRECOVERABLE_ERROR";
185  break;
187  stream << "ACL_CLIENT_REQUEST";
188  break;
190  stream << "ACL_DISABLED";
191  break;
193  stream << "DNS_TIMEDOUT";
194  break;
196  stream << "CONNECTION_TIMEDOUT";
197  break;
199  stream << "CONNECTION_THROTTLED";
200  break;
202  stream << "INVALID_AUTH";
203  break;
205  stream << "PING_TIMEDOUT";
206  break;
208  stream << "WRITE_TIMEDOUT";
209  break;
211  stream << "READ_TIMEDOUT";
212  break;
214  stream << "FAILURE_PROTOCOL_ERROR";
215  break;
217  stream << "INTERNAL_ERROR";
218  break;
220  stream << "SERVER_INTERNAL_ERROR";
221  break;
223  stream << "SERVER_SIDE_DISCONNECT";
224  break;
226  stream << "SERVER_ENDPOINT_CHANGED";
227  break;
228  }
229  return stream;
230 }
231 
232 } // namespace sdkInterfaces
233 } // namespace avsCommon
234 } // namespace alexaClientSDK
235 
236 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_SDKINTERFACES_INCLUDE_AVSCOMMON_SDKINTERFACES_CONNECTIONSTATUSOBSERVERINTERFACE_H_
virtual void onConnectionStatusChanged(const Status status, const std::vector< EngineConnectionStatus > &engineStatuses)
Definition: ConnectionStatusObserverInterface.h:141
ChangedReason
Definition: ConnectionStatusObserverInterface.h:50
The connection attempt failed due to the Connection object being disabled.
std::ostream & operator<<(std::ostream &stream, const AudioInputProcessorObserverInterface::State &state)
Definition: AudioInputProcessorObserverInterface.h:94
EngineConnectionStatus(const int connectEngineType, ChangedReason connectReason, Status connectStatus)
Definition: ConnectionStatusObserverInterface.h:107
Definition: ConnectionStatusObserverInterface.h:31
HTTP code for internal error by server which didn&#39;t fulfill the request.
Definition: HttpResponseCodes.h:45
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
The non-reason, to be used when no reason is specified (i.e. the &#39;unset&#39; value).
virtual void onConnectionStatusChanged(const Status status, const ChangedReason reason)=0
The connection status changed due to the client interacting with the Connection public api...
Status
Definition: ConnectionStatusObserverInterface.h:36
static const int ENGINE_TYPE_ALEXA_VOICE_SERVICES
Definition: ConnectionStatusObserverInterface.h:26

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