From ad1a9858cd0d15b1090a0977098b98307875f07c Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Thu, 13 Oct 2016 10:27:47 +0200 Subject: Added a stop condition for the client, When all the nodes have send a bye to the client, the client will shut down. --- client/cmixclient.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/cmixclient.cpp b/client/cmixclient.cpp index 1ffd904..933ad0e 100644 --- a/client/cmixclient.cpp +++ b/client/cmixclient.cpp @@ -43,14 +43,19 @@ void CMixClient::handle_message(int node_id, cmix_proto::CMixMessage message) handle_key_exchange(node_id, *message.mutable_keyexchange()); return; } + case cmix_proto::CMixMessage::ContentsCase::kBye: { + network_connections.at(node_id).close(); + if(std::all_of(network_connections.begin(), network_connections.end(), [](SenderReceiver const& c) { return c.is_open(); })) { + break; + } else { + return; + } + } default: { BOOST_LOG_TRIVIAL(error) << "Received unknown message"; } } - for(auto&& connection : network_connections) { - connection.close(); - } io_service.stop(); } -- cgit v1.2.3-70-g09d2