core: Make a place to implement the server-side websocket handling in C, conditionally.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m18s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 9m18s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "httpd.js.h"
|
||||
|
||||
#include "http.h"
|
||||
#include "log.h"
|
||||
#include "mem.h"
|
||||
#include "ssb.db.h"
|
||||
#include "ssb.h"
|
||||
@@ -8,6 +9,7 @@
|
||||
#include "util.js.h"
|
||||
|
||||
#include "picohttpparser.h"
|
||||
#include "uv.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -211,7 +213,12 @@ void tf_httpd_endpoint_app(tf_http_request_t* request)
|
||||
tf_ssb_run_work(ssb, _httpd_endpoint_app_blob_work, _httpd_endpoint_app_blob_after_work, data);
|
||||
}
|
||||
|
||||
void tf_httpd_endpoint_app_socket(tf_http_request_t* request)
|
||||
static void _tf_httpd_endpoint_app_socket_c(tf_http_request_t* request)
|
||||
{
|
||||
tf_printf("Unimplemented.\n");
|
||||
}
|
||||
|
||||
static void _tf_httpd_endpoint_app_socket_js(tf_http_request_t* request)
|
||||
{
|
||||
tf_task_t* task = request->user_data;
|
||||
tf_ssb_t* ssb = tf_task_get_ssb(task);
|
||||
@@ -250,3 +257,25 @@ void tf_httpd_endpoint_app_socket(tf_http_request_t* request)
|
||||
JS_FreeValue(context, exports);
|
||||
JS_FreeValue(context, global);
|
||||
}
|
||||
|
||||
void tf_httpd_endpoint_app_socket(tf_http_request_t* request)
|
||||
{
|
||||
static bool checked_env;
|
||||
static bool use_c;
|
||||
if (!checked_env)
|
||||
{
|
||||
char buffer[8] = { 0 };
|
||||
size_t buffer_size = sizeof(buffer);
|
||||
use_c = uv_os_getenv("TF_APP_C", buffer, &buffer_size) == 0 && strcmp(buffer, "1") == 0;
|
||||
checked_env = true;
|
||||
}
|
||||
|
||||
if (use_c)
|
||||
{
|
||||
_tf_httpd_endpoint_app_socket_c(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_httpd_endpoint_app_socket_js(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2402,7 +2402,6 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, const char* db_path
|
||||
|
||||
char buffer[8] = { 0 };
|
||||
size_t buffer_size = sizeof(buffer);
|
||||
buffer_size = sizeof(buffer);
|
||||
ssb->verbose = uv_os_getenv("TF_SSB_VERBOSE", buffer, &buffer_size) == 0 && strcmp(buffer, "1") == 0;
|
||||
|
||||
if (context)
|
||||
|
||||
Reference in New Issue
Block a user