diff --git a/MyClient.cpp b/MyClient.cpp index 449fec1..fd4f268 100644 --- a/MyClient.cpp +++ b/MyClient.cpp @@ -8,12 +8,16 @@ MyClient::MyClient(const char* host, int port) : TCPClient(host, port), tiretteS void MyClient::handleMessage(const std::string& message) { + std::string action = split(message, ";")[1]; // if get tirette => send tiretteState - if (split(message, ";")[1] == "tirette") { + if (action == "tirette") { if (split(message, ";")[2] == "get tirette_state") { const std::string toSend = "tirette;start;set tirette_state;" + std::to_string(*tiretteState); this->sendMessage(toSend.c_str()); } + } else if (action == "ping") + { + this->sendMessage("tirette;strat;pong;1"); } } diff --git a/main.cpp b/main.cpp index b261946..e5a4640 100644 --- a/main.cpp +++ b/main.cpp @@ -40,6 +40,7 @@ int main() { } // Attendre un court délai avant de vérifier à nouveau + lastEtat = etat; delay(100); }