core: Only the timeout remaing for the websocket handler in C?
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m2s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m2s
This commit is contained in:
@@ -291,7 +291,42 @@ static void _http_json_send(tf_http_request_t* request, JSContext* context, JSVa
|
||||
|
||||
static JSValue _httpd_app_on_tfrpc(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv, int magic, JSValue* func_data)
|
||||
{
|
||||
tf_printf("TODO: TFRPC\n");
|
||||
const char* id = tf_util_get_property_as_string(context, argv[0], "id");
|
||||
if (id)
|
||||
{
|
||||
JSClassID class_id = 0;
|
||||
app_t* app = JS_GetAnyOpaque(func_data[0], &class_id);
|
||||
JSValue process_app = JS_GetPropertyStr(context, app->process, "app");
|
||||
JSValue calls = JS_IsObject(process_app) ? JS_GetPropertyStr(context, process_app, "calls") : JS_UNDEFINED;
|
||||
JSValue call = JS_IsObject(calls) ? JS_GetPropertyStr(context, calls, id) : JS_UNDEFINED;
|
||||
if (!JS_IsUndefined(call))
|
||||
{
|
||||
JSValue error = JS_GetPropertyStr(context, argv[0], "error");
|
||||
if (!JS_IsUndefined(error))
|
||||
{
|
||||
JSValue reject = JS_GetPropertyStr(context, call, "reject");
|
||||
JSValue result = JS_Call(context, reject, JS_UNDEFINED, 1, &error);
|
||||
tf_util_report_error(context, result);
|
||||
JS_FreeValue(context, result);
|
||||
JS_FreeValue(context, reject);
|
||||
}
|
||||
else
|
||||
{
|
||||
JSValue resolve = JS_GetPropertyStr(context, call, "resolve");
|
||||
JSValue message_result = JS_GetPropertyStr(context, argv[0], "result");
|
||||
JSValue result = JS_Call(context, resolve, JS_UNDEFINED, 1, &message_result);
|
||||
JS_FreeValue(context, message_result);
|
||||
tf_util_report_error(context, result);
|
||||
JS_FreeValue(context, result);
|
||||
JS_FreeValue(context, resolve);
|
||||
}
|
||||
JS_FreeValue(context, error);
|
||||
}
|
||||
JS_FreeValue(context, call);
|
||||
JS_FreeValue(context, calls);
|
||||
JS_FreeValue(context, process_app);
|
||||
}
|
||||
JS_FreeCString(context, id);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
@@ -311,7 +346,6 @@ static JSValue _httpd_app_on_process_start(JSContext* context, JSValueConst this
|
||||
JSClassID class_id = 0;
|
||||
app_t* app = JS_GetAnyOpaque(func_data[0], &class_id);
|
||||
app->process = JS_DupValue(context, argv[0]);
|
||||
tf_printf("ON START %p => %s\n", app, app->request->path);
|
||||
|
||||
JSValue client_api = JS_GetPropertyStr(context, app->process, "client_api");
|
||||
JSValue tfrpc = JS_NewCFunctionData(context, _httpd_app_on_tfrpc, 1, 0, 1, func_data);
|
||||
@@ -319,10 +353,16 @@ static JSValue _httpd_app_on_process_start(JSContext* context, JSValueConst this
|
||||
JS_FreeValue(context, client_api);
|
||||
|
||||
JSValue process_app = JS_GetPropertyStr(context, app->process, "app");
|
||||
JSValue send = JS_NewCFunctionData(context, _httpd_app_on_output, 1, 0, 1, func_data);
|
||||
JS_SetPropertyStr(context, process_app, "_on_output", send);
|
||||
JSValue on_output = JS_NewCFunctionData(context, _httpd_app_on_output, 1, 0, 1, func_data);
|
||||
JS_SetPropertyStr(context, process_app, "_on_output", on_output);
|
||||
JS_FreeValue(context, process_app);
|
||||
|
||||
JSValue send = JS_GetPropertyStr(context, process_app, "send");
|
||||
JSValue result = JS_Call(context, send, process_app, 0, NULL);
|
||||
JS_FreeValue(context, send);
|
||||
tf_util_report_error(context, result);
|
||||
JS_FreeValue(context, result);
|
||||
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user