Commit 76736e73 authored by Gabriel Margiani's avatar Gabriel Margiani

fix clients answer handling.

parent 5068cb29
......@@ -118,21 +118,25 @@ std::string p3::client::get_input(const std::string & q, p3::client::inputType t
return in;
}
void p3::client::run() {
bool r = true;
while (r) {
std::string in = get_input("", COMMAND);
if (in == "exit" || in == "quit") {
break;
} else if ("events" == in) {
if(push_event_manager()) {
continue;
} else {
break;
}
bool p3::client::send_command() {
std::string in = get_input("", COMMAND);
if (in == "exit" || in == "quit") {
return false;
} else if ("events" == in) {
if(push_event_manager()) {
return send_command();
} else {
connection->send(p3::protocol::COMMAND, in);
return false;
}
} else {
connection->send(p3::protocol::COMMAND, in);
}
return true;
}
void p3::client::run() {
bool r = send_command();
while (r) {
p3::mQueueMessage m = connection->receive(-1);
bool print_list = true;
switch (m.get_command()) {
......@@ -173,6 +177,7 @@ void p3::client::run() {
default:
std::cout << "Unknown server command. " << m.get_value() << std::endl;
}
r = send_command();
}
}
......
......@@ -61,6 +61,8 @@ namespace p3 {
std::string get_input(const std::string & question, inputType is_command);
bool send_command();
public:
client(int argc, char *argv[]);
~client();
......
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