if (regex_match(line, rx_command))
{
- msg = Message();
- msg.command = line;
+ msg = Message(line);
state = State::Headers;
}
else
Message
ack()
{
- Message msg;
- msg.command = "ACK";
- return msg;
+ return Message("ACK");
}
Message
nack()
{
- Message msg;
- msg.command = "NACK";
- return msg;
+ return Message("NACK");
}
struct Message
{
+ Message() {}
+ Message(const std::string& command) : command(command) {}
+
std::string command;
std::map<std::string, std::string> headers;
std::string body;
if (msg.command == "_DISCONNECT")
return ack();
- Message a;
- a.command = "_ENOMETHOD";
- a.headers["Command"] = msg.command;
- return a;
+ Message reply("_ENOMETHOD");
+ reply.headers["Command"] = msg.command;
+ return reply;
}