From f40d4c1ddd8334c37975569c0d181737f7c4dc38 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Sun, 13 Oct 2024 22:13:05 +0200 Subject: [PATCH] add 'P' packet on UDP this can be used to check if UDP works :) --- src/TNetwork.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/TNetwork.cpp b/src/TNetwork.cpp index f89035a..243c9f2 100644 --- a/src/TNetwork.cpp +++ b/src/TNetwork.cpp @@ -112,9 +112,19 @@ void TNetwork::UDPServerMain() { try { ip::udp::endpoint remote_client_ep {}; std::vector Data = UDPRcvFromClient(remote_client_ep); - auto Pos = std::find(Data.begin(), Data.end(), ':'); - if (Data.empty() || Pos > Data.begin() + 2) + if (Data.empty()) { continue; + } + if (Data.size() == 1 && Data.at(0) == 'P') { + mUDPSock.send_to(const_buffer("P", 1), remote_client_ep, {}, ec); + // ignore errors + (void)ec; + continue; + } + auto Pos = std::find(Data.begin(), Data.end(), ':'); + if (Pos > Data.begin() + 2) { + continue; + } uint8_t ID = uint8_t(Data.at(0)) - 1; mServer.ForEachClient([&](std::weak_ptr ClientPtr) -> bool { std::shared_ptr Client;