Skip to content

Commit

Permalink
add 'P' packet on UDP
Browse files Browse the repository at this point in the history
this can be used to check if UDP works :)
  • Loading branch information
lionkor committed Oct 13, 2024
1 parent 4f052a3 commit f40d4c1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/TNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,19 @@ void TNetwork::UDPServerMain() {
try {
ip::udp::endpoint remote_client_ep {};
std::vector<uint8_t> Data = UDPRcvFromClient(remote_client_ep);
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 (Data.empty() || Pos > Data.begin() + 2)
if (Pos > Data.begin() + 2) {
continue;
}
uint8_t ID = uint8_t(Data.at(0)) - 1;
mServer.ForEachClient([&](std::weak_ptr<TClient> ClientPtr) -> bool {
std::shared_ptr<TClient> Client;
Expand Down

0 comments on commit f40d4c1

Please sign in to comment.