NUGU SDK Linux  1.7.5
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 #include <base/nugu_event.h>
22 
23 namespace NuguClientKit {
24 
37 enum class NetworkStatus {
38  DISCONNECTED,
39  CONNECTING,
40  READY,
41  CONNECTED
42 };
43 
44 enum class NetworkError {
45  FAILED,
46  TOKEN_ERROR,
47  UNKNOWN
48 };
49 
55 public:
56  virtual ~INetworkManagerListener() = default;
57 
62  virtual void onStatusChanged(NetworkStatus status);
63 
68  virtual void onError(NetworkError error);
69 
74  virtual void onEventSend(NuguEvent *nev);
75 
80  virtual void onEventAttachmentSend(NuguEvent *nev, int seq, bool is_end, size_t length, unsigned char *data);
81 
88  virtual void onEventSendResult(const char* msg_id, bool success, int code);
89 
96  virtual void onEventResponse(const char* msg_id, const char* data, bool success);
97 };
98 
104 public:
105  virtual ~INetworkManager() = default;
106 
111  virtual void addListener(INetworkManagerListener* listener) = 0;
112 
117  virtual void removeListener(INetworkManagerListener* listener) = 0;
118 
125  virtual bool connect() = 0;
126 
133  virtual bool disconnect() = 0;
134 
142  virtual bool setToken(const std::string& token) = 0;
143 
151  virtual bool setRegistryUrl(const std::string& url) = 0;
152 
161  virtual bool setUserAgent(const std::string& app_version, const std::string& additional_info = "") = 0;
162 };
163 
168 } // NuguClientKit
169 
170 #endif /* __NUGU_INETWORK_MANAGER_INTERFACE_H__ */
network manager listener interface
Definition: network_manager_interface.hh:54
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:103
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:37
NetworkError
Definition: network_manager_interface.hh:44
struct _nugu_event NuguEvent
Event object.
Definition: nugu_event.h:57