Still not syncing with the other clients I want but fighting to try to get it.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3701 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-12-22 19:57:34 +00:00
parent d4f7fdfc40
commit c616a16993
4 changed files with 54 additions and 16 deletions

View File

@ -404,7 +404,7 @@ static bool _tf_ssb_connection_get_request_callback(tf_ssb_connection_t* connect
return found;
}
static void _tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t request_number, tf_ssb_rpc_callback_t* callback, void* user_data)
void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t request_number, tf_ssb_rpc_callback_t* callback, void* user_data)
{
if (_tf_ssb_connection_get_request_callback(connection, request_number, NULL, NULL))
{
@ -443,7 +443,7 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
{
if (request_number > 0)
{
_tf_ssb_connection_add_request(connection, request_number, callback, user_data);
tf_ssb_connection_add_request(connection, request_number, callback, user_data);
}
uint8_t* combined = malloc(9 + size);
*combined = flags;
@ -939,16 +939,19 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
JSContext* context = connection->ssb->context;
JSValue val = JS_ParseJSON(context, (const char*)message, size, NULL);
if (JS_IsObject(val))
if (!JS_IsUndefined(val))
{
bool found = false;
for (tf_ssb_rpc_callback_node_t* it = connection->ssb->rpc; it; it = it->next)
if (JS_IsObject(val))
{
if (_tf_ssb_name_equals(context, val, it->name))
for (tf_ssb_rpc_callback_node_t* it = connection->ssb->rpc; it; it = it->next)
{
it->callback(connection, flags, request_number, JS_DupValue(context, val), NULL, 0, it->user_data);
found = true;
break;
if (_tf_ssb_name_equals(context, val, it->name))
{
it->callback(connection, flags, request_number, JS_DupValue(context, val), NULL, 0, it->user_data);
found = true;
break;
}
}
}
if (!found)
@ -970,6 +973,10 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
}
}
}
else
{
printf("Failed to parse %.*s\n", (int)size, message);
}
JS_FreeValue(context, val);
}