NUGU SDK Linux  1.7.6
NetworkManager

Network management. More...

+ Collaboration diagram for NetworkManager:

Classes

struct  nugu_network_server_policy
 Server policy information used for network connections. More...
 

Macros

#define NUGU_NETWORK_MAX_ADDRESS   255
 maximum size of address
 

Typedefs

typedef enum nugu_network_connection_type NuguNetworkConnectionType
 network connection type More...
 
typedef enum nugu_network_handoff_status NuguNetworkHandoffStatus
 network handoff status More...
 
typedef void(* NuguNetworkManagerAttachmentCallback) (const char *parent_msg_id, int seq, int is_end, const char *media_type, size_t length, const void *data, void *userdata)
 Callback prototype for receiving directive attachment. More...
 
typedef void(* NuguNetworkManagerDirectiveCallback) (NuguDirective *ndir, void *userdata)
 Callback prototype for receiving directive. More...
 
typedef void(* NuguNetworkManagerEventDataSendNotifyCallback) (NuguEvent *nev, int is_end, size_t length, unsigned char *data, void *userdata)
 Callback prototype for notification of event data sending requests. More...
 
typedef void(* NuguNetworkManagerEventResponseCallback) (int success, const char *event_msg_id, const char *event_dialog_id, const char *json, void *userdata)
 Callback prototype for directive response of event request. More...
 
typedef void(* NuguNetworkManagerEventResultCallback) (int success, const char *msg_id, const char *dialog_id, int code, void *userdata)
 Callback prototype for result of event transfer request. More...
 
typedef void(* NuguNetworkManagerEventSendNotifyCallback) (NuguEvent *nev, void *userdata)
 Callback prototype for notification of event sending requests. More...
 
typedef void(* NuguNetworkManagerHandoffStatusCallback) (NuguNetworkHandoffStatus status, void *userdata)
 Callback prototype for handoff status events.
 
typedef void(* NuguNetworkManagerStatusCallback) (NuguNetworkStatus status, void *userdata)
 Callback prototype for receiving network status events. More...
 
typedef struct nugu_network_server_policy NuguNetworkServerPolicy
 Server policy information used for network connections. More...
 
typedef enum nugu_network_status NuguNetworkStatus
 network status More...
 

Enumerations

enum  nugu_network_connection_type { NUGU_NETWORK_CONNECTION_ORIENTED , NUGU_NETWORK_CONNECTION_ONDEMAND }
 network connection type More...
 
enum  nugu_network_handoff_status { NUGU_NETWORK_HANDOFF_FAILED , NUGU_NETWORK_HANDOFF_READY , NUGU_NETWORK_HANDOFF_COMPLETED }
 network handoff status More...
 
enum  nugu_network_protocol { NUGU_NETWORK_PROTOCOL_H2 , NUGU_NETWORK_PROTOCOL_H2C , NUGU_NETWORK_PROTOCOL_UNKNOWN }
 network protocols More...
 
enum  nugu_network_status {
  NUGU_NETWORK_DISCONNECTED , NUGU_NETWORK_CONNECTING , NUGU_NETWORK_READY , NUGU_NETWORK_CONNECTED ,
  NUGU_NETWORK_FAILED , NUGU_NETWORK_TOKEN_ERROR
}
 network status More...
 

Functions

NUGU_API int nugu_network_manager_connect (void)
 Connect to server. More...
 
NUGU_API void nugu_network_manager_deinitialize (void)
 De-initialize the network manager.
 
NUGU_API int nugu_network_manager_disconnect (void)
 Disconnect from server. More...
 
NUGU_API int nugu_network_manager_force_close_event (NuguEvent *nev)
 Force close the NUGU_EVENT_TYPE_WITH_ATTACHMENT type event. More...
 
NUGU_API NuguNetworkConnectionType nugu_network_manager_get_connection_type (void)
 Get the connection type. More...
 
NUGU_API NuguNetworkStatus nugu_network_manager_get_status (void)
 Get the current network status. More...
 
NUGU_API int nugu_network_manager_handoff (const NuguNetworkServerPolicy *policy)
 Handoff the current connection to new server. More...
 
NUGU_API int nugu_network_manager_initialize (void)
 Initialize the network manager. More...
 
NUGU_API const char * nugu_network_manager_peek_last_asr_time (void)
 Get the last ASR event time information. More...
 
NUGU_API const char * nugu_network_manager_peek_registry_url (void)
 Get the device gateway registry url. More...
 
NUGU_API const char * nugu_network_manager_peek_token (void)
 Get the access token value. More...
 
NUGU_API const char * nugu_network_manager_peek_useragent (void)
 Get the UserAgent information. More...
 
NUGU_API int nugu_network_manager_reset_connection (void)
 Immediately disconnect the current connection and reconnect. More...
 
NUGU_API int nugu_network_manager_send_event (NuguEvent *nev)
 Send the event to server. More...
 
NUGU_API int nugu_network_manager_send_event_data (NuguEvent *nev, int is_end, size_t length, unsigned char *data)
 Send the attachment data of event to server. More...
 
NUGU_API int nugu_network_manager_set_attachment_callback (NuguNetworkManagerAttachmentCallback callback, void *userdata)
 Set attachment of directive receive callback. More...
 
NUGU_API int nugu_network_manager_set_connection_type (NuguNetworkConnectionType ctype)
 Set the connection type. More...
 
NUGU_API int nugu_network_manager_set_directive_callback (NuguNetworkManagerDirectiveCallback callback, void *userdata)
 Set directive receive callback. More...
 
NUGU_API int nugu_network_manager_set_event_data_send_notify_callback (NuguNetworkManagerEventDataSendNotifyCallback callback, void *userdata)
 Set event data send notify callback. More...
 
NUGU_API int nugu_network_manager_set_event_response_callback (NuguNetworkManagerEventResponseCallback callback, void *userdata)
 Set event response callback. More...
 
NUGU_API int nugu_network_manager_set_event_result_callback (NuguNetworkManagerEventResultCallback callback, void *userdata)
 Set event send result callback. More...
 
NUGU_API int nugu_network_manager_set_event_send_notify_callback (NuguNetworkManagerEventSendNotifyCallback callback, void *userdata)
 Set event send notify callback. More...
 
NUGU_API int nugu_network_manager_set_handoff_status_callback (NuguNetworkManagerHandoffStatusCallback callback, void *userdata)
 Set handoff status callback. More...
 
NUGU_API int nugu_network_manager_set_registry_url (const char *urlname)
 Set the device gateway registry url. More...
 
NUGU_API int nugu_network_manager_set_status (NuguNetworkStatus network_status)
 Set the current network status. More...
 
NUGU_API int nugu_network_manager_set_status_callback (NuguNetworkManagerStatusCallback callback, void *userdata)
 Set network status callback. More...
 
NUGU_API int nugu_network_manager_set_token (const char *token)
 Set the access token value. More...
 
NUGU_API int nugu_network_manager_set_useragent (const char *app_version, const char *additional_info)
 Set the HTTP header UserAgent information. More...
 

Detailed Description

Network management.

The network manager is responsible for managing connections and sending and receiving events and directives with the server.

Typedef Documentation

◆ NuguNetworkStatus

network status

Basic connection status flow for connection-oriented

  • Normal connection: DISCONNECTED -> CONNECTING -> CONNECTED
  • Connection failed: DISCONNECTED -> CONNECTING -> DISCONNECTED
  • Token error: DISCONNECTED -> CONNECTING -> TOKEN_ERROR -> DISCONNECTED

Basic connection status flow for connection-ondemand

  • Normal connection: DISCONNECTED -> CONNECTING -> READY
  • Connection failed: DISCONNECTED -> CONNECTING -> DISCONNECTED
  • Token error: DISCONNECTED -> CONNECTING -> TOKEN_ERROR -> DISCONNECTED

Connection recovery flow for connection-oriented

  • Connection recovered: CONNECTED -> CONNECTING -> CONNECTED
  • Recovery failed: CONNECTED -> CONNECTING -> DISCONNECTED
  • Token error: CONNECTED -> CONNECTING -> TOKEN_ERROR -> DISCONNECTED
See also
nugu_network_manager_set_status()
nugu_network_manager_get_status()
NetworkManagerStatusCallback

◆ NuguNetworkConnectionType

◆ NuguNetworkManagerStatusCallback

typedef void(* NuguNetworkManagerStatusCallback) (NuguNetworkStatus status, void *userdata)

Callback prototype for receiving network status events.

See also
nugu_network_manager_set_status_callback()

◆ NuguNetworkHandoffStatus

network handoff status

See also
nugu_network_manager_set_handoff_status_callback()
NetworkManagerHandoffStatusCallback

◆ NuguNetworkManagerEventSendNotifyCallback

typedef void(* NuguNetworkManagerEventSendNotifyCallback) (NuguEvent *nev, void *userdata)

Callback prototype for notification of event sending requests.

See also
nugu_network_manager_send_event()
nugu_network_manager_set_event_send_notify_callback()

◆ NuguNetworkManagerEventDataSendNotifyCallback

typedef void(* NuguNetworkManagerEventDataSendNotifyCallback) (NuguEvent *nev, int is_end, size_t length, unsigned char *data, void *userdata)

Callback prototype for notification of event data sending requests.

See also
nugu_network_manager_send_event_data()
nugu_network_manager_set_event_data_send_notify_callback()

◆ NuguNetworkManagerEventResultCallback

typedef void(* NuguNetworkManagerEventResultCallback) (int success, const char *msg_id, const char *dialog_id, int code, void *userdata)

Callback prototype for result of event transfer request.

See also
nugu_network_manager_send_event()
nugu_network_manager_set_event_result_callback()

◆ NuguNetworkManagerEventResponseCallback

typedef void(* NuguNetworkManagerEventResponseCallback) (int success, const char *event_msg_id, const char *event_dialog_id, const char *json, void *userdata)

Callback prototype for directive response of event request.

See also
nugu_network_manager_send_event()
nugu_network_manager_set_event_response_callback()

◆ NuguNetworkManagerDirectiveCallback

typedef void(* NuguNetworkManagerDirectiveCallback) (NuguDirective *ndir, void *userdata)

Callback prototype for receiving directive.

See also
nugu_network_manager_set_directive_callback()

◆ NuguNetworkManagerAttachmentCallback

typedef void(* NuguNetworkManagerAttachmentCallback) (const char *parent_msg_id, int seq, int is_end, const char *media_type, size_t length, const void *data, void *userdata)

Callback prototype for receiving directive attachment.

See also
nugu_network_manager_set_attachment_callback()

◆ NuguNetworkServerPolicy

Server policy information used for network connections.

See also
nugu_network_manager_handoff

Enumeration Type Documentation

◆ nugu_network_status

network status

Basic connection status flow for connection-oriented

  • Normal connection: DISCONNECTED -> CONNECTING -> CONNECTED
  • Connection failed: DISCONNECTED -> CONNECTING -> DISCONNECTED
  • Token error: DISCONNECTED -> CONNECTING -> TOKEN_ERROR -> DISCONNECTED

Basic connection status flow for connection-ondemand

  • Normal connection: DISCONNECTED -> CONNECTING -> READY
  • Connection failed: DISCONNECTED -> CONNECTING -> DISCONNECTED
  • Token error: DISCONNECTED -> CONNECTING -> TOKEN_ERROR -> DISCONNECTED

Connection recovery flow for connection-oriented

  • Connection recovered: CONNECTED -> CONNECTING -> CONNECTED
  • Recovery failed: CONNECTED -> CONNECTING -> DISCONNECTED
  • Token error: CONNECTED -> CONNECTING -> TOKEN_ERROR -> DISCONNECTED
See also
nugu_network_manager_set_status()
nugu_network_manager_get_status()
NetworkManagerStatusCallback
Enumerator
NUGU_NETWORK_DISCONNECTED 

Network disconnected

NUGU_NETWORK_CONNECTING 

Connection in progress

NUGU_NETWORK_READY 

Network ready for ondemand connection type

NUGU_NETWORK_CONNECTED 

Network connected

NUGU_NETWORK_FAILED 

Failed to connect to all servers

NUGU_NETWORK_TOKEN_ERROR 

Token error

◆ nugu_network_connection_type

network connection type

See also
nugu_network_manager_set_connection_type()
nugu_network_manager_get_connection_type()
Enumerator
NUGU_NETWORK_CONNECTION_ORIENTED 

Always connected

NUGU_NETWORK_CONNECTION_ONDEMAND 

Connect when sending an event

◆ nugu_network_handoff_status

network handoff status

See also
nugu_network_manager_set_handoff_status_callback()
NetworkManagerHandoffStatusCallback
Enumerator
NUGU_NETWORK_HANDOFF_FAILED 

Handoff failed

NUGU_NETWORK_HANDOFF_READY 

The handoff connection is ready but not yet switched.

NUGU_NETWORK_HANDOFF_COMPLETED 

The transition to the handoff connection is complete.

◆ nugu_network_protocol

network protocols

Enumerator
NUGU_NETWORK_PROTOCOL_H2 

HTTP/2 with TLS

NUGU_NETWORK_PROTOCOL_H2C 

HTTP/2 over clean TCP

NUGU_NETWORK_PROTOCOL_UNKNOWN 

Unknown protocol

Function Documentation

◆ nugu_network_manager_set_status_callback()

NUGU_API int nugu_network_manager_set_status_callback ( NuguNetworkManagerStatusCallback  callback,
void *  userdata 
)

Set network status callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_handoff_status_callback()

NUGU_API int nugu_network_manager_set_handoff_status_callback ( NuguNetworkManagerHandoffStatusCallback  callback,
void *  userdata 
)

Set handoff status callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_event_send_notify_callback()

NUGU_API int nugu_network_manager_set_event_send_notify_callback ( NuguNetworkManagerEventSendNotifyCallback  callback,
void *  userdata 
)

Set event send notify callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_event_data_send_notify_callback()

NUGU_API int nugu_network_manager_set_event_data_send_notify_callback ( NuguNetworkManagerEventDataSendNotifyCallback  callback,
void *  userdata 
)

Set event data send notify callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_event_result_callback()

NUGU_API int nugu_network_manager_set_event_result_callback ( NuguNetworkManagerEventResultCallback  callback,
void *  userdata 
)

Set event send result callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_event_response_callback()

NUGU_API int nugu_network_manager_set_event_response_callback ( NuguNetworkManagerEventResponseCallback  callback,
void *  userdata 
)

Set event response callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_directive_callback()

NUGU_API int nugu_network_manager_set_directive_callback ( NuguNetworkManagerDirectiveCallback  callback,
void *  userdata 
)

Set directive receive callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_attachment_callback()

NUGU_API int nugu_network_manager_set_attachment_callback ( NuguNetworkManagerAttachmentCallback  callback,
void *  userdata 
)

Set attachment of directive receive callback.

Parameters
[in]callbackcallback function
[in]userdatadata to pass to the user callback
Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_status()

NUGU_API int nugu_network_manager_set_status ( NuguNetworkStatus  network_status)

Set the current network status.

Parameters
[in]network_statusnetwork status
Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_get_status()

◆ nugu_network_manager_get_status()

NUGU_API NuguNetworkStatus nugu_network_manager_get_status ( void  )

Get the current network status.

Returns
NuguNetworkStatus network status
See also
nugu_network_manager_set_status()

◆ nugu_network_manager_send_event()

NUGU_API int nugu_network_manager_send_event ( NuguEvent nev)

Send the event to server.

Parameters
[in]nevevent object
Returns
result
Return values
0success
-1failure
See also
nugu_event_new()
nugu_network_manager_send_event_data()
nugu_network_manager_force_close_event()

◆ nugu_network_manager_send_event_data()

NUGU_API int nugu_network_manager_send_event_data ( NuguEvent nev,
int  is_end,
size_t  length,
unsigned char *  data 
)

Send the attachment data of event to server.

Parameters
[in]nevevent object
[in]is_enddata is last(is_end=1) or not(is_end=0)
[in]lengthlength of data
[in]datadata to send
Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_send_event()

◆ nugu_network_manager_force_close_event()

NUGU_API int nugu_network_manager_force_close_event ( NuguEvent nev)

Force close the NUGU_EVENT_TYPE_WITH_ATTACHMENT type event.

Parameters
[in]nevevent object
Returns
result
Return values
0success
-1failure
See also
nugu_event_set_type()

◆ nugu_network_manager_initialize()

NUGU_API int nugu_network_manager_initialize ( void  )

Initialize the network manager.

Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_connect()

NUGU_API int nugu_network_manager_connect ( void  )

Connect to server.

Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_disconnect()

◆ nugu_network_manager_disconnect()

NUGU_API int nugu_network_manager_disconnect ( void  )

Disconnect from server.

Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_connect()

◆ nugu_network_manager_handoff()

NUGU_API int nugu_network_manager_handoff ( const NuguNetworkServerPolicy policy)

Handoff the current connection to new server.

Returns
result
Return values
0success
-1failure

When a handoff request is received, the client tries to connect to another server while maintaining the current connection.

  • If the handoff connection is successful, change the current connection to the new server.
  • If the handoff connection fails, disconnect all connections and start over from the Registry step.
  • If the handoff connection is lost, start again from the Registry step.

◆ nugu_network_manager_reset_connection()

NUGU_API int nugu_network_manager_reset_connection ( void  )

Immediately disconnect the current connection and reconnect.

Returns
result
Return values
0success
-1failure

◆ nugu_network_manager_set_token()

NUGU_API int nugu_network_manager_set_token ( const char *  token)

Set the access token value.

Parameters
[in]tokenaccess token
Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_peek_token()

◆ nugu_network_manager_peek_token()

NUGU_API const char* nugu_network_manager_peek_token ( void  )

Get the access token value.

Returns
access token value. Please do not modify the data manually.
See also
nugu_network_manager_set_token()

◆ nugu_network_manager_set_registry_url()

NUGU_API int nugu_network_manager_set_registry_url ( const char *  urlname)

Set the device gateway registry url.

Parameters
[in]urlnamegateway registry url
Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_peek_registry_url()

◆ nugu_network_manager_peek_registry_url()

NUGU_API const char* nugu_network_manager_peek_registry_url ( void  )

Get the device gateway registry url.

Returns
gateway registry url. Please do not modify the data manually.
See also
nugu_network_manager_set_registry_url()

◆ nugu_network_manager_set_useragent()

NUGU_API int nugu_network_manager_set_useragent ( const char *  app_version,
const char *  additional_info 
)

Set the HTTP header UserAgent information.

Parameters
[in]app_versionapplication version (e.g. "0.1.0")
[in]additional_infoadditional information or NULL
Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_peek_useragent()

◆ nugu_network_manager_peek_useragent()

NUGU_API const char* nugu_network_manager_peek_useragent ( void  )

Get the UserAgent information.

Returns
UserAgent information. Please do not modify the data manually.
See also
nugu_network_manager_set_useragent()

◆ nugu_network_manager_peek_last_asr_time()

NUGU_API const char* nugu_network_manager_peek_last_asr_time ( void  )

Get the last ASR event time information.

Returns
Last-Asr-Event-Time. Please do not modify the data manually.

◆ nugu_network_manager_set_connection_type()

NUGU_API int nugu_network_manager_set_connection_type ( NuguNetworkConnectionType  ctype)

Set the connection type.

Parameters
ctypeconnection type
Returns
result
Return values
0success
-1failure
See also
nugu_network_manager_get_connection_type()

◆ nugu_network_manager_get_connection_type()

NUGU_API NuguNetworkConnectionType nugu_network_manager_get_connection_type ( void  )

Get the connection type.

Returns
network connection type
See also
nugu_network_manager_set_connection_type()