diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 3a9bb4d740..05ec42be8b 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -145,6 +145,7 @@ namespace rpcn rpcn_client::~rpcn_client() { + terminate_connection(); std::lock_guard lock(inst_mutex); terminate = true; sem_rpcn.release(); @@ -414,7 +415,7 @@ namespace rpcn command == CommandType::AddBlock || command == CommandType::RemoveBlock || command == CommandType::SendMessage || command == CommandType::SendToken || command == CommandType::SendResetToken || command == CommandType::ResetPassword || - command == CommandType::GetNetworkTime || command == CommandType::SetPresence) + command == CommandType::GetNetworkTime || command == CommandType::SetPresence || command == CommandType::Terminate) { std::lock_guard lock(mutex_replies_sync); replies_sync.insert(std::make_pair(packet_id, std::make_pair(command, std::move(data)))); @@ -574,23 +575,20 @@ namespace rpcn if (res == 0) { // Remote closed connection - rpcn_log.error("recv failed: connection reset by server"); + rpcn_log.notice("recv failed: connection reset by server"); return recvn_result::recvn_noconn; } rpcn_log.error("recvn failed with error: %d:%s(native: %d)", res, get_wolfssl_error(read_wssl, res), get_native_error()); return recvn_result::recvn_fatal; } - - res = 0; } else { // Reset timeout each time something is received num_timeouts = 0; + n_recv += res; } - - n_recv += res; } return recvn_result::recvn_success; @@ -1017,6 +1015,21 @@ namespace rpcn return true; } + bool rpcn_client::terminate_connection() + { + u64 req_id = rpcn_request_counter.fetch_add(1); + + std::vector packet_data; + std::vector data; + + if (!forge_send_reply(CommandType::Terminate, req_id, data, packet_data)) + { + return false; + } + + return true; + } + ErrorType rpcn_client::create_user(std::string_view npid, std::string_view password, std::string_view online_name, std::string_view avatar_url, std::string_view email) { std::vector data; diff --git a/rpcs3/Emu/NP/rpcn_client.h b/rpcs3/Emu/NP/rpcn_client.h index a9974241ae..082a3bc60f 100644 --- a/rpcs3/Emu/NP/rpcn_client.h +++ b/rpcs3/Emu/NP/rpcn_client.h @@ -407,6 +407,7 @@ namespace rpcn static std::shared_ptr get_instance(bool check_config = false); rpcn_state wait_for_connection(); rpcn_state wait_for_authentified(); + bool terminate_connection(); void get_friends_and_register_cb(friend_data& friend_infos, friend_cb_func cb_func, void* cb_param); void remove_friend_cb(friend_cb_func, void* cb_param);