• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# NetConn_NetConnCallback
2
3## Overview
4
5Defines network status callbacks.
6
7**Since**: 12
8
9**Related module**: [NetConnection](_net_connection.md)
10
11**Header file**: [net_connection_type.h](net__connection__type_8h.md#net_connection_typeh)
12
13## Summary
14
15### Member Variables
16
17| Name| Description|
18| -------- | -------- |
19| [onNetworkAvailable](#onnetworkavailable) | Called when the network is available.|
20| [onNetCapabilitiesChange](#onnetcapabilitieschange) | Called when the network capabilities change.|
21| [onConnetionProperties](#onconnetionproperties) | Called when network connection properties change.|
22| [onNetLost](#onnetlost) | Called when the network is disconnected.|
23| [onNetUnavailable](#onnetunavailable) | Called when the network is unavailable. This callback is triggered when the network is not activated within the specified timeout interval. If the timeout interval is not set, this callback is not triggered.|
24
25
26## Member Variable Description
27
28
29### onNetworkAvailable
30
31```
32typedef void (*OH_NetConn_NetworkAvailable)(NetConn_NetHandle *netHandle)
33```
34
35**Description**
36
37Called when the network is available.
38
39**Description**
40
41After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.
42
43**Parameters**
44
45| Name| Type| Description|
46| -------- | -------- | -------- |
47| netHandle |[NetHandle](js-apis-net-connection.md#nethandle) | Network handle.|
48
49### onNetCapabilitiesChange
50
51```
52typedef void (*OH_NetConn_NetCapabilitiesChange)(NetConn_NetHandle *netHandle, NetConn_NetCapabilities *netCapabilities)
53```
54
55**Description**
56
57Called when the network capabilities change.
58
59**Description**
60
61After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.
62
63**Parameters**
64
65| Name| Type| Description|
66| -------- | -------- | -------- |
67| netHandle | [NetHandle](js-apis-net-connection.md#nethandle) | Network handle.|
68| netCapabilities | [NetCapabilities](js-apis-net-connection.md#netcapabilities)| Network capability set.|
69
70### onConnetionProperties
71
72```
73typedef void (*OH_NetConn_NetConnectionPropertiesChange)(NetConn_NetHandle *netHandle, NetConn_ConnectionProperties *connConnetionProperties)
74```
75
76**Description**
77
78Called when network connection properties change.
79
80**Description**
81
82After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.
83
84**Parameters**
85
86| Name| Type| Description|
87| -------- | -------- | -------- |
88| netHandle |[NetHandle](js-apis-net-connection.md#nethandle) | Network handle.|
89| connConnetionProperties | [ConnectionProperties](js-apis-net-connection.md#connectionproperties)| Network connection properties.|
90
91### onNetLost
92
93```
94typedef void (*OH_NetConn_NetLost)(NetConn_NetHandle *netHandle)
95```
96
97**Description**
98
99Called when the network is disconnected.
100
101**Description**
102
103After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.
104
105**Parameters**
106
107| Name| Type| Description|
108| -------- | -------- | -------- |
109| netHandle |[NetHandle](js-apis-net-connection.md#nethandle)| Network handle.|
110
111### onNetUnavailable
112
113```
114typedef void (*OH_NetConn_NetUnavailable)(void)
115```
116
117**Description**
118
119Called when the network is unavailable. This callback is triggered when the network is not activated within the specified timeout interval. If the timeout interval is not set, this callback is not triggered.
120