diff --git a/client/main.js b/client/main.js index 0f90b49..827ebb4 100644 --- a/client/main.js +++ b/client/main.js @@ -9,6 +9,7 @@ window.libcurl = (function() { const websocket_url = `wss://${location.hostname}/ws/`; var event_loop = null; +var active_requests = 0 //a case insensitive dictionary for request headers class Headers { @@ -76,6 +77,7 @@ function perform_request(url, params, js_data_callback, js_end_callback, body=nu _free(response_json_ptr); if (error != 0) console.error("request failed with error code " + error); + active_requests --; js_end_callback(error, response_info); } @@ -90,11 +92,14 @@ function perform_request(url, params, js_data_callback, js_end_callback, body=nu _start_request(url_ptr, params_ptr, data_callback_ptr, end_callback_ptr, body_ptr, body_length); _free(params_ptr); + active_requests ++; _tick_request(); if (!event_loop) { event_loop = setInterval(() => { - _tick_request(); - if (!_active_requests()) { + if (_active_requests() || active_requests) { + _tick_request(); + } + else { clearInterval(event_loop); event_loop = null; } @@ -190,7 +195,7 @@ function main() { Module.onRuntimeInitialized = main; return { fetch: libcurl_fetch, - set_websocket: set_websocket_url, + set_websocket: set_websocket_url } })() \ No newline at end of file diff --git a/client/wisp_client b/client/wisp_client index 0a80885..79ebf15 160000 --- a/client/wisp_client +++ b/client/wisp_client @@ -1 +1 @@ -Subproject commit 0a80885090b6247f42bc07cc85b441d8d719f551 +Subproject commit 79ebf1517a17cfbeb427a3c6bea788c3e30704f6 diff --git a/server/wisp_server b/server/wisp_server index 8747346..a74dcab 160000 --- a/server/wisp_server +++ b/server/wisp_server @@ -1 +1 @@ -Subproject commit 874734623e4dfc4652b34a1bc61e1e35ca86dee8 +Subproject commit a74dcabec6d8564a2e245421e710fff7928a99fb