mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 23:35:41 +00:00
Add 'P' packet on UDP (#379)
This can be used to check if UDP works :) I've tested this a bit with snep ingame, even spamming this on localhost with a large number of connections seems to not impact gameplay at all.
This commit is contained in:
commit
03b0bd4d2c
@ -112,9 +112,19 @@ void TNetwork::UDPServerMain() {
|
|||||||
try {
|
try {
|
||||||
ip::udp::endpoint remote_client_ep {};
|
ip::udp::endpoint remote_client_ep {};
|
||||||
std::vector<uint8_t> Data = UDPRcvFromClient(remote_client_ep);
|
std::vector<uint8_t> Data = UDPRcvFromClient(remote_client_ep);
|
||||||
auto Pos = std::find(Data.begin(), Data.end(), ':');
|
if (Data.empty()) {
|
||||||
if (Data.empty() || Pos > Data.begin() + 2)
|
|
||||||
continue;
|
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;
|
uint8_t ID = uint8_t(Data.at(0)) - 1;
|
||||||
mServer.ForEachClient([&](std::weak_ptr<TClient> ClientPtr) -> bool {
|
mServer.ForEachClient([&](std::weak_ptr<TClient> ClientPtr) -> bool {
|
||||||
std::shared_ptr<TClient> Client;
|
std::shared_ptr<TClient> Client;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user