client/Response: new Client wrapper class for writing responses

This commit is contained in:
Max Kellermann
2015-08-06 22:10:25 +02:00
parent b1480167be
commit 7652a2986b
49 changed files with 1068 additions and 780 deletions

View File

@@ -21,9 +21,9 @@
#include "NeighborCommands.hxx"
#include "Request.hxx"
#include "client/Client.hxx"
#include "client/Response.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
#include "protocol/Result.hxx"
#include "neighbor/Glue.hxx"
#include "neighbor/Info.hxx"
#include "util/ConstBuffer.hxx"
@@ -42,19 +42,19 @@ neighbor_commands_available(const Instance &instance)
CommandResult
handle_listneighbors(Client &client, gcc_unused Request args)
{
Response r(client);
const NeighborGlue *const neighbors =
client.partition.instance.neighbors;
if (neighbors == nullptr) {
command_error(client, ACK_ERROR_UNKNOWN,
"No neighbor plugin configured");
r.Error(ACK_ERROR_UNKNOWN, "No neighbor plugin configured");
return CommandResult::ERROR;
}
for (const auto &i : neighbors->GetList())
client_printf(client,
"neighbor: %s\n"
"name: %s\n",
i.uri.c_str(),
i.display_name.c_str());
r.Format("neighbor: %s\n"
"name: %s\n",
i.uri.c_str(),
i.display_name.c_str());
return CommandResult::OK;
}