mirror of
https://github.com/webui-dev/webui
synced 2025-03-28 21:13:17 +00:00
* Update `CLOSE` command * Update bridge
This commit is contained in:
parent
349dbad06b
commit
94a3db07b7
File diff suppressed because it is too large
Load Diff
@ -209,7 +209,7 @@ class WebuiBridge {
|
||||
|
||||
this.#ws.onmessage = async (event) => {
|
||||
const buffer8 = new Uint8Array(event.data)
|
||||
if (buffer8.length < 4) return
|
||||
if (buffer8.length < 2) return
|
||||
if (buffer8[0] !== this.#HEADER_SIGNATURE) return
|
||||
|
||||
if(this.#isTextBasedCommand(buffer8[1])) {
|
||||
@ -269,7 +269,7 @@ class WebuiBridge {
|
||||
// 1: [CMD]
|
||||
|
||||
console.log(`WebUI -> Close`)
|
||||
globalThis.close()
|
||||
this.#ws.close()
|
||||
break
|
||||
case this.#HEADER_JS_QUICK:
|
||||
case this.#HEADER_JS:
|
||||
|
@ -166,7 +166,7 @@ WEBUI_EXPORT void webui_destroy(size_t window);
|
||||
WEBUI_EXPORT void webui_exit(void);
|
||||
// Set the web-server root folder path for a specific window.
|
||||
WEBUI_EXPORT bool webui_set_root_folder(size_t window, const char* path);
|
||||
// Set the web-server root folder path for all windows.
|
||||
// Set the web-server root folder path for all windows. Should be used before webui_show().
|
||||
WEBUI_EXPORT bool webui_set_default_root_folder(const char* path);
|
||||
// Set a custom handler to serve files
|
||||
WEBUI_EXPORT void webui_set_file_handler(size_t window, const void* (*handler)(const char* filename, int* length));
|
||||
|
@ -881,19 +881,17 @@ void webui_exit(void) {
|
||||
|
||||
#ifndef WEBUI_LOG
|
||||
// Close all opened windows
|
||||
// by sending `close` command
|
||||
// by sending `CLOSE` command
|
||||
|
||||
// Prepare packets
|
||||
char* packet = (char*) _webui_malloc(4);
|
||||
packet[0] = WEBUI_HEADER_SIGNATURE; // Signature
|
||||
packet[1] = WEBUI_HEADER_CLOSE; // CMD
|
||||
packet[2] = 0; // ID
|
||||
packet[3] = 0; // Data
|
||||
for(size_t i = 1; i <= _webui_core.last_win_number; i++) {
|
||||
if(_webui_core.wins[i] != NULL) {
|
||||
if(_webui_core.wins[i]->connected) {
|
||||
// Send packet
|
||||
_webui_window_send(_webui_core.wins[i], packet, 4);
|
||||
_webui_window_send(_webui_core.wins[i], packet, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3850,10 +3848,9 @@ static void _webui_window_send(_webui_window_t* win, char* packet, size_t packet
|
||||
printf("[Core]\t\t_webui_window_send() -> Packet hex : [ ");
|
||||
_webui_print_hex(packet, packets_size);
|
||||
printf("]\n");
|
||||
printf("[Core]\t\t_webui_window_send() -> Packet str : [%.*s] \n", (int)(packets_size - 3), (const char*)&packet[3]);
|
||||
#endif
|
||||
|
||||
if(!win->connected || packet == NULL || packets_size < 4)
|
||||
if(!win->connected || packet == NULL || packets_size < 2)
|
||||
return;
|
||||
|
||||
int ret = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user