From 020873d353fe36e6f6e7ea133ee5f74f5fc48493 Mon Sep 17 00:00:00 2001 From: MouriNaruto Date: Sat, 6 Jul 2024 00:55:58 +0800 Subject: [PATCH] Simplify NanaGet::JsonRpc2::RequestMessage because NanaGet::JsonRpc2::NotificationMessage is existed. --- NanaGet/NanaGet.JsonRpc2.cpp | 5 +---- NanaGet/NanaGet.JsonRpc2.h | 6 ++---- NanaGet/NanaGetCore.cpp | 1 - 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/NanaGet/NanaGet.JsonRpc2.cpp b/NanaGet/NanaGet.JsonRpc2.cpp index 0dcc023..16c0492 100644 --- a/NanaGet/NanaGet.JsonRpc2.cpp +++ b/NanaGet/NanaGet.JsonRpc2.cpp @@ -19,10 +19,7 @@ std::string NanaGet::JsonRpc2::FromRequestMessage( ResultJson["jsonrpc"] = "2.0"; ResultJson["method"] = Value.Method; ResultJson["params"] = nlohmann::json::parse(Value.Parameters); - if (!Value.IsNotification) - { - ResultJson["id"] = Value.Identifier; - } + ResultJson["id"] = Value.Identifier; return ResultJson.dump(2); } catch (...) diff --git a/NanaGet/NanaGet.JsonRpc2.h b/NanaGet/NanaGet.JsonRpc2.h index 8c2c47b..bbcf933 100644 --- a/NanaGet/NanaGet.JsonRpc2.h +++ b/NanaGet/NanaGet.JsonRpc2.h @@ -29,10 +29,6 @@ namespace NanaGet::JsonRpc2 */ struct RequestMessage { - /** - * @brief true if this request is a notification. Otherwise false. - */ - bool IsNotification = false; /** * @brief A string containing the name of the method to be invoked. * method names that begin with the word rpc followed by a period @@ -40,12 +36,14 @@ namespace NanaGet::JsonRpc2 * methods and extensions and MUST NOT be used for anything else. */ std::string Method; + /** * @brief A structured JSON value that holds the parameter values to be * used during the invocation of the method. This member MAY be * omitted. */ std::string Parameters; + /** * @brief An identifier established by the client. If it is not included * it is assumed to be a notification. The value SHOULD normally diff --git a/NanaGet/NanaGetCore.cpp b/NanaGet/NanaGetCore.cpp index e13e52a..a5d5989 100644 --- a/NanaGet/NanaGetCore.cpp +++ b/NanaGet/NanaGetCore.cpp @@ -486,7 +486,6 @@ std::string NanaGet::Aria2Instance::SimpleJsonRpcCall( std::string const& Parameters) { NanaGet::JsonRpc2::RequestMessage Request; - Request.IsNotification = false; Request.Method = MethodName; Request.Parameters = Parameters; Request.Identifier = winrt::to_string(NanaGet::CreateGuidString());