diff --git a/eRPC/Response.cpp b/eRPC/Response.cpp index 152cc4e..fb60b35 100644 --- a/eRPC/Response.cpp +++ b/eRPC/Response.cpp @@ -4,10 +4,6 @@ namespace eRPC { - Response::Response() : msgid(-1), ok(false), result() - { - } - Response::Response(int msgid, bool ok, std::string result) : msgid(msgid), ok(ok), result(result) { diff --git a/eRPC/Response.hpp b/eRPC/Response.hpp index 55304a0..05c4831 100644 --- a/eRPC/Response.hpp +++ b/eRPC/Response.hpp @@ -8,8 +8,6 @@ namespace eRPC class Response { public: - Response(); - /** * Construct a response with the given message ID, status, and result. */ diff --git a/eRPC/Server.cpp b/eRPC/Server.cpp index cd286b2..5bb99fa 100644 --- a/eRPC/Server.cpp +++ b/eRPC/Server.cpp @@ -7,6 +7,7 @@ #include #include #include +#include namespace eRPC { @@ -61,26 +62,26 @@ namespace eRPC std::cout << "Received request:\n" << request.serialize() << std::endl; - Response response; + std::unique_ptr response; if (methods.find(request.getMethod()) != methods.end()) { std::function method = methods[request.getMethod()]; method(); - response = Response( + response = std::make_unique(Response( request.getMsgid(), true, - "RESULTS HERE"); + "RESULTS HERE")); } else { - response = Response( + response = std::make_unique(Response( request.getMsgid(), false, - "Method \"" + request.getMethod() + "\" not found"); + "Method not found")); } - std::string serialized = response.serialize(); + std::string serialized = response->serialize(); write(connfd, serialized.c_str(), serialized.size() + 1); close(connfd);