Skip to content

Commit 51d82c8

Browse files
committed
tk
1 parent 0346f0f commit 51d82c8

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

include/webui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,9 @@ WEBUI_EXPORT bool webui_set_port(size_t window, size_t port);
712712
*
713713
* @return Returns a free port
714714
*
715-
* @example int port = _webui_get_free_port(); webui_set_port(myWindow, port);
715+
* @example int port = webui_get_free_port(); webui_set_port(myWindow, port);
716716
*/
717-
WEBUI_EXPORT size_t _webui_get_free_port(void);
717+
WEBUI_EXPORT size_t webui_get_free_port(void);
718718

719719
/**
720720
* @brief Control the WebUI behaviour. It's recommended to be called at the beginning.

include/webui.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class window {
181181
void set_port(size_t port) const { webui_set_port(webui_window, port); }
182182

183183
// Get an available network port to be used by your app or by WebUI.
184-
size_t get_free_port() { _webui_get_free_port(); }
184+
size_t get_free_port() { webui_get_free_port(); }
185185

186186
// Set window position
187187
void set_position(unsigned int x, unsigned int y) const { webui_set_position(webui_window, x, y); }

src/webui.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static void * _webui_run_browser_task(void * _arg);
473473
static void _webui_init(void);
474474
static bool _webui_show(_webui_window_t* win, struct mg_connection* client, const char* content, size_t browser);
475475
static bool _webui_get_cb_index(_webui_window_t* win, const char* element, size_t* id);
476-
// static size_t _webui_get_free_port(void); // now in headers
476+
static size_t _webui_get_free_port(void);
477477
static void _webui_free_port(size_t port);
478478
static char* _webui_get_current_path(void);
479479
static void _webui_send_client_ws(_webui_window_t* win, struct mg_connection* client,
@@ -2071,6 +2071,18 @@ size_t webui_get_parent_process_id(size_t window) {
20712071
return win->process_id;
20722072
}
20732073

2074+
size_t webui_get_free_port(void) {
2075+
2076+
#ifdef WEBUI_LOG
2077+
printf("[User] webui_get_free_port()\n");
2078+
#endif
2079+
2080+
// Initialization
2081+
_webui_init();
2082+
2083+
return _webui_get_free_port();
2084+
}
2085+
20742086
#ifdef WEBUI_TLS
20752087
static bool _webui_check_certificate(const char* certificate_pem, const char* private_key_pem) {
20762088

@@ -7294,7 +7306,7 @@ static void _webui_free_port(size_t port) {
72947306
}
72957307
}
72967308

7297-
size_t _webui_get_free_port(void) {
7309+
static size_t _webui_get_free_port(void) {
72987310

72997311
#ifdef WEBUI_LOG
73007312
printf("[Core]\t\t_webui_get_free_port()\n");

0 commit comments

Comments
 (0)