Trying to understand what's up with rooms. Various minor fixes and improvements.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4113 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
13
src/ssb.c
13
src/ssb.c
@ -294,7 +294,7 @@ static void _tf_ssb_connection_close(tf_ssb_connection_t* connection, const char
|
||||
else if (connection->state == k_tf_ssb_state_verified ||
|
||||
connection->state == k_tf_ssb_state_server_verified)
|
||||
{
|
||||
printf("Connection %p is closing: %s.\n", connection, reason);
|
||||
printf("Connection %s %p is closing: %s.\n", connection->name, connection, reason);
|
||||
connection->state = k_tf_ssb_state_closing;
|
||||
_tf_ssb_connection_send_close(connection);
|
||||
}
|
||||
@ -999,7 +999,10 @@ int tf_ssb_connection_get_port(tf_ssb_connection_t* connection)
|
||||
|
||||
bool tf_ssb_connection_get_id(tf_ssb_connection_t* connection, char* out_id, size_t out_id_size)
|
||||
{
|
||||
return tf_ssb_id_bin_to_str(out_id, out_id_size, connection->serverpub);
|
||||
return
|
||||
connection &&
|
||||
memcmp(connection->serverpub, (uint8_t[k_id_bin_len]) { 0 }, k_id_bin_len) != 0 &&
|
||||
tf_ssb_id_bin_to_str(out_id, out_id_size, connection->serverpub);
|
||||
}
|
||||
|
||||
static bool _tf_ssb_is_already_connected(tf_ssb_t* ssb, uint8_t* id, tf_ssb_connection_t* ignore_connection)
|
||||
@ -1273,7 +1276,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
||||
connection->ssb->rpc_in++;
|
||||
if (size == 0)
|
||||
{
|
||||
_tf_ssb_connection_close(connection, "read zero");
|
||||
_tf_ssb_connection_close(connection, "rpc recv zero");
|
||||
return;
|
||||
}
|
||||
else if (flags & k_ssb_rpc_flag_json)
|
||||
@ -1282,7 +1285,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
||||
tf_ssb_id_bin_to_str(id, sizeof(id), connection->serverpub);
|
||||
if (connection->ssb->verbose)
|
||||
{
|
||||
printf(CYAN "%s RPC RECV" RESET " from %s flags=%x RN=%d: %.*s\n", connection->name, id, flags, request_number, (int)size, message);
|
||||
printf(CYAN "%s RPC RECV" RESET " from %s flags=%x RN=%d: [%zd B] %.*s\n", connection->name, id, flags, request_number, size, (int)size, message);
|
||||
}
|
||||
JSContext* context = connection->ssb->context;
|
||||
JSValue val = JS_ParseJSON(context, (const char*)message, size, NULL);
|
||||
@ -1712,7 +1715,7 @@ static void _tf_ssb_connection_on_tcp_recv_internal(tf_ssb_connection_t* connect
|
||||
}
|
||||
else
|
||||
{
|
||||
_tf_ssb_connection_close(connection, "read zero");
|
||||
_tf_ssb_connection_close(connection, uv_strerror(nread));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user