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

fix clients answer handling.

parent 5068cb29
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -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) {
bool p3::client::send_command() {
	std::string in = get_input("", COMMAND);
	if (in == "exit" || in == "quit") {
			break;
		return false;
	} else if ("events" == in) {
		if(push_event_manager()) {
				continue;
			return send_command();
		} else {
				break;
			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();
	}
}

+2 −0
Original line number Diff line number Diff line
@@ -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();