forked from cory/tildefriends
Fix websocket unmasking issues. Autotest works with C httpd, now.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4699 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -147,15 +147,15 @@ static JSValue _httpd_response_send(JSContext* context, JSValueConst this_val, i
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static void _httpd_message_callback(tf_http_request_t* request, const void* data, size_t size)
|
||||
static void _httpd_message_callback(tf_http_request_t* request, int op_code, const void* data, size_t size)
|
||||
{
|
||||
JSContext* context = request->context;
|
||||
JSValue response_object = JS_MKPTR(JS_TAG_OBJECT, request->user_data);
|
||||
JSValue on_message = JS_GetPropertyStr(context, response_object, "onMessage");
|
||||
|
||||
JSValue event = JS_NewObject(context);
|
||||
JS_SetPropertyStr(context, event, "opCode", JS_NewInt32(context, 0x1));
|
||||
JS_SetPropertyStr(context, event, "data", JS_NewStringLen(context, data, size)); //tf_util_new_uint8_array(context, data, size);
|
||||
JS_SetPropertyStr(context, event, "opCode", JS_NewInt32(context, op_code));
|
||||
JS_SetPropertyStr(context, event, "data", JS_NewStringLen(context, data, size));
|
||||
JSValue response = JS_Call(context, on_message, JS_UNDEFINED, 1, &event);
|
||||
tf_util_report_error(context, response);
|
||||
JS_FreeValue(context, event);
|
||||
@ -270,7 +270,9 @@ static JSValue _httpd_register_socket_handler(JSContext* context, JSValueConst t
|
||||
static JSValue _httpd_start(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
{
|
||||
tf_http_t* http = JS_GetOpaque(this_val, _httpd_class_id);
|
||||
tf_http_listen(http, 12345);
|
||||
int port = 0;
|
||||
JS_ToInt32(context, &port, argv[0]);
|
||||
tf_http_listen(http, port);
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
@ -319,7 +321,7 @@ void tf_httpd_register(JSContext* context)
|
||||
JS_SetPropertyStr(context, httpd, "handlers", JS_NewObject(context));
|
||||
JS_SetPropertyStr(context, httpd, "all", JS_NewCFunction(context, _httpd_all, "all", 2));
|
||||
JS_SetPropertyStr(context, httpd, "registerSocketHandler", JS_NewCFunction(context, _httpd_register_socket_handler, "register_socket_handler", 2));
|
||||
JS_SetPropertyStr(context, httpd, "start", JS_NewCFunction(context, _httpd_start, "start", 0));
|
||||
JS_SetPropertyStr(context, httpd, "start", JS_NewCFunction(context, _httpd_start, "start", 1));
|
||||
JS_SetPropertyStr(context, global, "httpdc", httpd);
|
||||
JS_FreeValue(context, global);
|
||||
}
|
||||
|
Reference in New Issue
Block a user