Commit 082831e2 authored by louiz’'s avatar louiz’

[network] Make it possible to request an answer but have a different command name in the answer.

parent 0975d3e6
......@@ -136,11 +136,11 @@ void CommandHandler::install_read_handler(void)
boost::asio::placeholders::bytes_transferred));
}
void CommandHandler::request_answer(Command* command, t_read_callback on_answer)
void CommandHandler::request_answer(Command* command, t_read_callback on_answer, std::string name)
{
// We may want to send a command that do not require an answer.
if (on_answer)
this->install_callback_once(command->get_name(), on_answer);
if (name.size() == 0)
name = command->get_name();
this->install_callback_once(name, on_answer);
this->send(command);
}
......
......@@ -49,7 +49,7 @@ public:
* Sends a command, and use install_callback_once to wait for the answer
* and call that callback to handle it.
*/
void request_answer(Command*, t_read_callback on_answer = 0);
void request_answer(Command*, t_read_callback on_answer, std::string name = "");
/**
* Install a new callback associated with a command. This callback will
* be called upon receiving that command.
......@@ -120,7 +120,7 @@ private:
command_queue commands_to_send;
/**
* Tells us if we are waiting for an async_write to finish or note.
* Tells us if we are waiting for an async_write to finish or not.
* This must be set to true when calling async_write(), to false
* in the write handler. It is used by check_commands_to_send.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment