mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 22:10:01 -04:00
don't hardcode websocket url
This commit is contained in:
parent
663f31cd6e
commit
57d1245c40
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
@ -25,4 +25,3 @@ $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 ./
|
|
@ -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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue