MCPcopy Create free account
hub / github.com/FastLED/FastLED / js_fetch_success_callback

Function js_fetch_success_callback

src/platforms/wasm/js_fetch.cpp.hpp:97–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95
96// C++ callback function that JavaScript can call when fetch completes
97extern "C" EMSCRIPTEN_KEEPALIVE void js_fetch_success_callback(u32 request_id, const char* content) {
98 FL_WARN("Fetch success callback received for request " << request_id << ", content length: " << strlen(content));
99
100 auto callback_opt = getCallbackManager().takeCallback(request_id);
101 if (callback_opt) {
102 // Create a successful response object using unified fl::response
103 fl::net::http::Response response(200, "OK");
104 response.set_body(fl::string(content));
105 response.set_header("content-type", "text/html"); // Default content type
106
107 (*callback_opt)(response);
108 } else {
109 FL_WARN("Warning: No pending callback found for fetch success request " << request_id);
110 }
111 // Wake any pthread parked inside fl::platforms::await().
112 fl::platforms::ICoroutineRuntime::instance().wakeWaiters();
113}
114
115// C++ error callback function that JavaScript can call when fetch fails
116extern "C" EMSCRIPTEN_KEEPALIVE void js_fetch_error_callback(u32 request_id, const char* error_message) {

Callers

nothing calls this directly

Calls 6

strlenFunction · 0.85
takeCallbackMethod · 0.80
set_bodyMethod · 0.80
set_headerMethod · 0.80
wakeWaitersMethod · 0.80
stringClass · 0.50

Tested by

no test coverage detected