diff --git a/TCPServer.cpp b/TCPServer.cpp index f3f66a6..68381c4 100644 --- a/TCPServer.cpp +++ b/TCPServer.cpp @@ -151,6 +151,7 @@ void TCPServer::handleMessage(const std::string& message, int clientSocket) break; } } + checkIfAllClientsReady(); } else if (tokens[0] == "gc") { if (tokens[2] == "axis") { @@ -341,6 +342,23 @@ void TCPServer::start() std::thread([this]() { acceptConnections(); }).detach(); } +void TCPServer::checkIfAllClientsReady() { + bool allReady = true; + for (auto&[name, socket, isReady] : clients) + { + if (!isReady) + { + // std::cout << name << " is not ready" << std::endl; + allReady = false; + } + } + + if (allReady) + { + this->broadcastMessage("strat;all;ready;1\n"); + } +} + void TCPServer::toggleBras() { brasBaisser = !brasBaisser; if (brasBaisser) { diff --git a/TCPServer.h b/TCPServer.h index cc0ea58..fe3a7ae 100644 --- a/TCPServer.h +++ b/TCPServer.h @@ -110,6 +110,8 @@ public: void handleEmergency(); + void checkIfAllClientsReady(); + void toggleBras(); void togglePince(int pince);