Browse Source

Send echo request to update latency statistics every 5 seconds

pull/8276/head
staphen 4 months ago committed by Anders Jenbo
parent
commit
642ba322c4
  1. 6
      Source/dvlnet/base.cpp
  2. 1
      Source/dvlnet/base.h

6
Source/dvlnet/base.cpp

@ -226,6 +226,12 @@ tl::expected<void, PacketError> base::RecvLocal(packet &pkt)
bool base::SNetReceiveMessage(uint8_t *sender, void **data, size_t *size)
{
uint32_t now = SDL_GetTicks();
if (now == 0) now++;
if (lastEchoTime == 0 || now - lastEchoTime > 5000) {
for (plr_t i = 0; i < Players.size(); i++)
SendEchoRequest(i);
}
poll();
if (message_queue.empty())
return false;

1
Source/dvlnet/base.h

@ -90,6 +90,7 @@ protected:
private:
std::array<PlayerState, MAX_PLRS> playerStateTable_;
bool awaitingSequenceNumber_ = true;
uint32_t lastEchoTime = 0;
plr_t GetOwner();
bool AllTurnsArrived();

Loading…
Cancel
Save