diff --git a/client/build.sh b/client/build.sh index ded13ae..2754790 100755 --- a/client/build.sh +++ b/client/build.sh @@ -10,7 +10,7 @@ OUT_FILE="out/libcurl.js" EXPORTED_FUNCS="_load_certs,_perform_request" RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL" COMPILER_OPTIONS="-o $OUT_FILE -lcurl -lssl -lcrypto -lcjson -I $INCLUDE_DIR -L $LIB_DIR" -EMSCRIPTEN_OPTIONS="-lwebsocket.js -sWEBSOCKET_URL=wss://debug.ading.dev/ws -sSINGLE_FILE -sASYNCIFY -sALLOW_TABLE_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS" +EMSCRIPTEN_OPTIONS="-lwebsocket.js -sSINGLE_FILE -sASYNCIFY -sALLOW_TABLE_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS" tools/all_deps.sh tools/generate_cert.sh @@ -24,5 +24,4 @@ $COMPILE_CMD #patch the output to work around some emscripten bugs sed -i 's/err("__syscall_getsockname " \?+ \?fd);//' $OUT_FILE -sed -i 's/function _emscripten_console_error(str) {/& if(UTF8ToString(str).endsWith("__syscall_setsockopt\\n")) return;/' $OUT_FILE -mv out/libcurl.data ./ \ No newline at end of file +sed -i 's/function _emscripten_console_error(str) {/& if(UTF8ToString(str).endsWith("__syscall_setsockopt\\n")) return;/' $OUT_FILE \ No newline at end of file diff --git a/client/main.js b/client/main.js index 44aad58..5e6d96e 100644 --- a/client/main.js +++ b/client/main.js @@ -1,4 +1,3 @@ -const cacert_path = "./out/cacert.pem"; const websocket_url = `wss://${location.hostname}/ws`; const status_messages = { @@ -218,14 +217,18 @@ function libcurl_fetch(url, params={}) { }) } +function set_websocket_url(url) { + Module.websocket.url = url; +} + async function main() { console.log("emscripten module loaded"); _load_certs(); + set_websocket_url(websocket_url); console.log(await libcurl_fetch("https://httpbin.org/anything")); } window.onload = () => { console.log("page loaded, waiting for emscripten module load"); - //Module.websocket.url = websocket_url; Module.onRuntimeInitialized = main; }; \ No newline at end of file