add name to debug print, update ping time each packet

This commit is contained in:
Lion Kortlepel 2021-03-30 15:57:16 +02:00
parent b524aa67de
commit 667bd7f7c8
3 changed files with 3 additions and 2 deletions

View File

@ -81,7 +81,7 @@ TClient::TClient(TServer& Server)
void TClient::UpdatePingTime() { void TClient::UpdatePingTime() {
mLastPingTime = std::chrono::high_resolution_clock::now(); mLastPingTime = std::chrono::high_resolution_clock::now();
debug(std::string("ping time updated!: ") + ((SecondsSinceLastPing() == 0) ? "OK" : "ERR")); debug(GetName() + ": " + std::string("ping time updated!: ") + ((SecondsSinceLastPing() == 0) ? "OK" : "ERR"));
} }
int TClient::SecondsSinceLastPing() { int TClient::SecondsSinceLastPing() {
auto seconds = std::chrono::duration_cast<std::chrono::seconds>( auto seconds = std::chrono::duration_cast<std::chrono::seconds>(

View File

@ -467,6 +467,8 @@ std::string TNetwork::TCPRcv(TClient& c) {
//debug("Parsing from " + c->GetName() + " -> " +std::to_string(Ret.size())); //debug("Parsing from " + c->GetName() + " -> " +std::to_string(Ret.size()));
#endif #endif
c.UpdatePingTime();
return Ret; return Ret;
} }

View File

@ -96,7 +96,6 @@ void TServer::GlobalParser(const std::weak_ptr<TClient>& Client, std::string Pac
case 'p': case 'p':
Network.Respond(*LockedClient, ("p"), false); Network.Respond(*LockedClient, ("p"), false);
Network.UpdatePlayer(*LockedClient); Network.UpdatePlayer(*LockedClient);
LockedClient->UpdatePingTime();
return; return;
case 'O': case 'O':
if (Packet.length() > 1000) { if (Packet.length() > 1000) {