Skip to content

Commit

Permalink
Simplify NanaGet::JsonRpc2::RequestMessage because NanaGet::JsonRpc2:…
Browse files Browse the repository at this point in the history
…:NotificationMessage is existed.
  • Loading branch information
MouriNaruto committed Jul 5, 2024
1 parent c9377ad commit 020873d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions NanaGet/NanaGet.JsonRpc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (...)
Expand Down
6 changes: 2 additions & 4 deletions NanaGet/NanaGet.JsonRpc2.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,21 @@ 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
* character (U+002E or ASCII 46) are reserved for rpc-internal
* 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
Expand Down
1 change: 0 additions & 1 deletion NanaGet/NanaGetCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 020873d

Please sign in to comment.