NUGU SDK Linux  1.7.6
network_manager_interface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 SK Telecom Co., Ltd. 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  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __NUGU_NETWORK_MANAGER_INTERFACE_H__
18 #define __NUGU_NETWORK_MANAGER_INTERFACE_H__
19 
20 #include <string>
21 
22 #include <base/nugu_event.h>
23 #include <nugu.h>
24 
25 namespace NuguClientKit {
26 
39 enum class NetworkStatus {
40  DISCONNECTED,
41  CONNECTING,
42  READY,
43  CONNECTED
44 };
45 
46 enum class NetworkError {
47  FAILED,
48  TOKEN_ERROR,
49  UNKNOWN
50 };
51 
56 class NUGU_API INetworkManagerListener {
57 public:
58  virtual ~INetworkManagerListener() = default;
59 
64  virtual void onStatusChanged(NetworkStatus status);
65 
70  virtual void onError(NetworkError error);
71 
76  virtual void onEventSend(NuguEvent* nev);
77 
82  virtual void onEventAttachmentSend(NuguEvent* nev, int seq, bool is_end, size_t length, unsigned char* data);
83 
90  virtual void onEventSendResult(const char* msg_id, bool success, int code);
91 
98  virtual void onEventResponse(const char* msg_id, const char* data, bool success);
99 };
100 
105 class NUGU_API INetworkManager {
106 public:
107  virtual ~INetworkManager() = default;
108 
113  virtual void addListener(INetworkManagerListener* listener) = 0;
114 
119  virtual void removeListener(INetworkManagerListener* listener) = 0;
120 
127  virtual bool connect() = 0;
128 
135  virtual bool disconnect() = 0;
136 
144  virtual bool setToken(const std::string& token) = 0;
145 
153  virtual bool setRegistryUrl(const std::string& url) = 0;
154 
163  virtual bool setUserAgent(const std::string& app_version, const std::string& additional_info = "") = 0;
164 };
165 
170 } // NuguClientKit
171 
172 #endif /* __NUGU_INETWORK_MANAGER_INTERFACE_H__ */
network manager listener interface
Definition: network_manager_interface.hh:56
virtual void onStatusChanged(NetworkStatus status)
Report the connection status with the NUGU server.
virtual void onEventAttachmentSend(NuguEvent *nev, int seq, bool is_end, size_t length, unsigned char *data)
Report that the attachment will be sent to the server.
virtual void onEventSend(NuguEvent *nev)
Report that the event will be sent to the server.
virtual void onEventResponse(const char *msg_id, const char *data, bool success)
Report the response data received from the server.
virtual void onEventSendResult(const char *msg_id, bool success, int code)
Report the result of sending an event from the server.
virtual void onError(NetworkError error)
Report an error while communicating with the NUGU server.
network manager interface
Definition: network_manager_interface.hh:105
virtual void addListener(INetworkManagerListener *listener)=0
Add the Listener object.
virtual bool setToken(const std::string &token)=0
Set the access token value. The connection type is automatically set through token analysis.
virtual bool setUserAgent(const std::string &app_version, const std::string &additional_info="")=0
Set the HTTP header UserAgent information.
virtual bool setRegistryUrl(const std::string &url)=0
Set the device gateway registry url.
virtual void removeListener(INetworkManagerListener *listener)=0
Remove the Listener object.
virtual bool disconnect()=0
Request a disconnection with the NUGU server.
virtual bool connect()=0
Request a connection with the NUGU server.
NetworkStatus
Definition: network_manager_interface.hh:39
NetworkError
Definition: network_manager_interface.hh:46
struct _nugu_event NuguEvent
Event object.
Definition: nugu_event.h:59