Remove unnecessary constructor
Using cool smart pointers too wowie!
This commit is contained in:
parent
33d8277dc3
commit
ed64fb05b1
@ -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)
|
||||
{
|
||||
|
@ -8,8 +8,6 @@ namespace eRPC
|
||||
class Response
|
||||
{
|
||||
public:
|
||||
Response();
|
||||
|
||||
/**
|
||||
* Construct a response with the given message ID, status, and result.
|
||||
*/
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
namespace eRPC
|
||||
{
|
||||
@ -61,26 +62,26 @@ namespace eRPC
|
||||
std::cout << "Received request:\n"
|
||||
<< request.serialize() << std::endl;
|
||||
|
||||
Response response;
|
||||
std::unique_ptr<Response> response;
|
||||
if (methods.find(request.getMethod()) != methods.end())
|
||||
{
|
||||
std::function<void *()> method = methods[request.getMethod()];
|
||||
method();
|
||||
|
||||
response = Response(
|
||||
response = std::make_unique<Response>(Response(
|
||||
request.getMsgid(),
|
||||
true,
|
||||
"RESULTS HERE");
|
||||
"RESULTS HERE"));
|
||||
}
|
||||
else
|
||||
{
|
||||
response = Response(
|
||||
response = std::make_unique<Response>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user