mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 22:10:01 -04:00
add wisp support
This commit is contained in:
parent
248d5b0161
commit
95121068bc
5 changed files with 17 additions and 5 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "client/wisp_client"]
|
||||||
|
path = client/wisp_client
|
||||||
|
url = https://github.com/mercuryWorkshop/wisp-client-js
|
|
@ -8,11 +8,12 @@ OUT_FILE="out/libcurl.js"
|
||||||
ES6_FILE="out/libcurl_module.mjs"
|
ES6_FILE="out/libcurl_module.mjs"
|
||||||
MODULE_FILE="out/emscripten_compiled.js"
|
MODULE_FILE="out/emscripten_compiled.js"
|
||||||
WRAPPER_SOURCE="main.js"
|
WRAPPER_SOURCE="main.js"
|
||||||
|
WISP_CLIENT="wisp_client"
|
||||||
|
|
||||||
EXPORTED_FUNCS="_init_curl,_start_request,_request_loop"
|
EXPORTED_FUNCS="_init_curl,_start_request,_request_loop"
|
||||||
RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
|
RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL"
|
||||||
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -I $INCLUDE_DIR -L $LIB_DIR"
|
COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lssl -lcrypto -lcjson -lz -lbrotlidec -lbrotlicommon -I $INCLUDE_DIR -L $LIB_DIR"
|
||||||
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASYNCIFY -sASYNCIFY_ONLY=start_request,request_loop -sALLOW_TABLE_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
|
EMSCRIPTEN_OPTIONS="-lwebsocket.js -sASYNCIFY -sASYNCIFY_ONLY=start_request,request_loop -sASSERTIONS=1 -sALLOW_TABLE_GROWTH -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS"
|
||||||
|
|
||||||
if [ "$1" = "release" ]; then
|
if [ "$1" = "release" ]; then
|
||||||
COMPILER_OPTIONS="-O3 -flto $COMPILER_OPTIONS"
|
COMPILER_OPTIONS="-O3 -flto $COMPILER_OPTIONS"
|
||||||
|
@ -44,6 +45,11 @@ cp $WRAPPER_SOURCE $OUT_FILE
|
||||||
sed -i "/__emscripten_output__/r $MODULE_FILE" $OUT_FILE
|
sed -i "/__emscripten_output__/r $MODULE_FILE" $OUT_FILE
|
||||||
rm $MODULE_FILE
|
rm $MODULE_FILE
|
||||||
|
|
||||||
|
#add wisp libraries
|
||||||
|
sed -i "s/new WebSocketConstructor/new WispWebSocket/" $OUT_FILE
|
||||||
|
sed -i "/__wisp_libraries__/r $WISP_CLIENT/polyfill.js" $OUT_FILE
|
||||||
|
sed -i "/__wisp_libraries__/r $WISP_CLIENT/wisp.js" $OUT_FILE
|
||||||
|
|
||||||
#generate es6 module
|
#generate es6 module
|
||||||
cp $OUT_FILE $ES6_FILE
|
cp $OUT_FILE $ES6_FILE
|
||||||
sed -i 's/window.libcurl/export const libcurl/' $ES6_FILE
|
sed -i 's/window.libcurl/export const libcurl/' $ES6_FILE
|
|
@ -50,15 +50,14 @@ void request_loop() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ensure we dont block the main thread
|
||||||
|
emscripten_sleep(0);
|
||||||
|
|
||||||
int msgq = 0;
|
int msgq = 0;
|
||||||
curl_msg = curl_multi_info_read(multi_handle, &msgq);
|
curl_msg = curl_multi_info_read(multi_handle, &msgq);
|
||||||
if (curl_msg && curl_msg->msg == CURLMSG_DONE) {
|
if (curl_msg && curl_msg->msg == CURLMSG_DONE) {
|
||||||
finish_request(curl_msg);
|
finish_request(curl_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure we dont block the main thread
|
|
||||||
emscripten_sleep(0);
|
|
||||||
|
|
||||||
} while(request_active);
|
} while(request_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ window.libcurl = (function() {
|
||||||
//emscripten compiled code is inserted here
|
//emscripten compiled code is inserted here
|
||||||
/* __emscripten_output__ */
|
/* __emscripten_output__ */
|
||||||
|
|
||||||
|
//wisp client code goes here
|
||||||
|
/* __wisp_libraries__ */
|
||||||
|
|
||||||
const websocket_url = `wss://${location.hostname}/ws/`;
|
const websocket_url = `wss://${location.hostname}/ws/`;
|
||||||
|
|
||||||
const status_messages = {
|
const status_messages = {
|
||||||
|
|
1
client/wisp_client
Submodule
1
client/wisp_client
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 0a80885090b6247f42bc07cc85b441d8d719f551
|
Loading…
Add table
Add a link
Reference in a new issue