GeezerVison is showing github.com — Add service-callback to wpcp_lws_main · WebProcessControl/libwpcp@ab62ed5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: include/wpcp_lws_main.h +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,6 +13,8 @@ struct wpcp_lws_main_t { |
13 | 13 | const char* (*handle_argument)(const char* name, const char* value); |
14 | 14 | void (*start)(struct wpcp_lws_t* wpcp_lws); |
15 | 15 | void (*stop)(struct wpcp_lws_t* wpcp_lws); |
| 16 | + int service_timeout_ms; |
| 17 | + void (*service)(struct wpcp_lws_t* wpcp_lws); |
16 | 18 | }; |
17 | 19 |
|
18 | 20 | typedef void (*wpcp_lws_init_cleanup_function_t)(struct wpcp_lws_main_t* lws); |
|
Collapse file
Copy file name to clipboardExpand all lines: src/wpcp_lws_main.c +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -178,6 +178,7 @@ int wpcp_lws_main(int argc, char* argv[], wpcp_lws_init_cleanup_function_t init, |
178 | 178 |
|
179 | 179 | g_wpcp_lws_main.argc = argc; |
180 | 180 | g_wpcp_lws_main.argv = argv; |
| 181 | + g_wpcp_lws_main.service_timeout_ms = 500; |
181 | 182 |
|
182 | 183 | if (init) |
183 | 184 | init(&g_wpcp_lws_main); |
@@ -190,8 +191,12 @@ int wpcp_lws_main(int argc, char* argv[], wpcp_lws_init_cleanup_function_t init, |
190 | 191 | if (g_wpcp_lws_main.start) |
191 | 192 | g_wpcp_lws_main.start(g_wpcp_lws); |
192 | 193 |
|
193 | | - while (!force_exit) |
194 | | - wpcp_lws_service(g_wpcp_lws, 500); |
| 194 | + while (!force_exit) { |
| 195 | + wpcp_lws_service(g_wpcp_lws, g_wpcp_lws_main.service_timeout_ms); |
| 196 | + |
| 197 | + if (g_wpcp_lws_main.service) |
| 198 | + g_wpcp_lws_main.service(g_wpcp_lws); |
| 199 | + } |
195 | 200 |
|
196 | 201 | if (g_wpcp_lws_main.stop) |
197 | 202 | g_wpcp_lws_main.stop(g_wpcp_lws); |
|