forked from cory/tildefriends
Some ebt.replicate success.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3703 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -408,6 +408,7 @@ void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t requ
|
||||
{
|
||||
if (_tf_ssb_connection_get_request_callback(connection, request_number, NULL, NULL))
|
||||
{
|
||||
/* TODO: This leaks the callback. */
|
||||
return;
|
||||
}
|
||||
tf_ssb_request_t* request = malloc(sizeof(tf_ssb_request_t));
|
||||
@ -661,6 +662,7 @@ static void _tf_ssb_connection_verify_identity(tf_ssb_connection_t* connection,
|
||||
|
||||
JSContext* context = connection->ssb->context;
|
||||
JS_SetPropertyStr(context, connection->object, "id", JS_NewString(context, fullid));
|
||||
JS_SetPropertyStr(context, connection->object, "is_client", JS_TRUE);
|
||||
|
||||
connection->state = k_tf_ssb_state_verified;
|
||||
_tf_ssb_notify_connections_changed(connection->ssb, k_tf_ssb_change_connect, connection);
|
||||
@ -866,6 +868,7 @@ static void _tf_ssb_connection_verify_client_identity(tf_ssb_connection_t* conne
|
||||
|
||||
JSContext* context = connection->ssb->context;
|
||||
JS_SetPropertyStr(context, connection->object, "id", JS_NewString(context, fullid));
|
||||
JS_SetPropertyStr(context, connection->object, "is_client", JS_FALSE);
|
||||
|
||||
connection->state = k_tf_ssb_state_server_verified;
|
||||
_tf_ssb_notify_connections_changed(connection->ssb, k_tf_ssb_change_connect, connection);
|
||||
@ -967,7 +970,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* k_unsupported = "{\"message\": \"unsupported message\", \"name\": \"Error\", \"stack\": \"none\"}";
|
||||
const char* k_unsupported = "{\"message\": \"method: is not in list of allowed methods\", \"name\": \"Error\", \"stack\": \"none\"}";
|
||||
tf_ssb_connection_rpc_send(connection, k_ssb_rpc_flag_json | k_ssb_rpc_flag_end_error | (flags & k_ssb_rpc_flag_stream), -request_number,
|
||||
(const uint8_t*)k_unsupported, strlen(k_unsupported), NULL, NULL);
|
||||
}
|
||||
@ -1322,7 +1325,6 @@ static void _tf_ssb_connection_on_connect(uv_connect_t* connect, int status)
|
||||
connect->data = NULL;
|
||||
if (status == 0)
|
||||
{
|
||||
printf("on connect\n");
|
||||
connection->state = k_tf_ssb_state_connected;
|
||||
uv_read_start(connect->handle, _tf_ssb_connection_on_tcp_alloc, _tf_ssb_connection_on_tcp_recv);
|
||||
_tf_ssb_connection_client_send_hello(connect->handle);
|
||||
@ -1812,6 +1814,7 @@ tf_ssb_connection_t* tf_ssb_connection_create(tf_ssb_t* ssb, const char* host, c
|
||||
if (tf_ssb_id_bin_to_str(public_key_str, sizeof(public_key_str), public_key))
|
||||
{
|
||||
JS_SetPropertyStr(context, connection->object, "id", JS_NewString(context, public_key_str));
|
||||
JS_SetPropertyStr(context, connection->object, "is_client", JS_TRUE);
|
||||
}
|
||||
JS_SetOpaque(connection->object, connection);
|
||||
|
||||
|
@ -352,13 +352,18 @@ static JSValue _tf_ssb_rpc_send_json(JSContext* context, JSValueConst this_val,
|
||||
JS_ToInt32(context, &request_number, request_val);
|
||||
JS_FreeValue(context, request_val);
|
||||
|
||||
JSValue flags_val = JS_GetPropertyStr(context, this_val, "flags");
|
||||
int32_t flags_number;
|
||||
JS_ToInt32(context, &flags_number, flags_val);
|
||||
JS_FreeValue(context, flags_val);
|
||||
|
||||
JSValue message_val = JS_JSONStringify(context, argv[0], JS_NULL, JS_NULL);
|
||||
size_t size;
|
||||
const char* message = JS_ToCStringLen(context, &size, message_val);
|
||||
|
||||
tf_ssb_connection_rpc_send(
|
||||
connection,
|
||||
k_ssb_rpc_flag_json | k_ssb_rpc_flag_stream,
|
||||
k_ssb_rpc_flag_json | (flags_number & ~k_ssb_rpc_mask_type),
|
||||
-request_number,
|
||||
(const uint8_t*)message,
|
||||
size,
|
||||
|
Reference in New Issue
Block a user