diff options
author | Mattes D <github@xoft.cz> | 2014-12-07 15:46:27 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-12-07 15:46:27 +0100 |
commit | 3c3cb198f33fd55b9cb20188cc42034b21660d21 (patch) | |
tree | 282d86969d4a2cbad5a64a27d1e17a5bad8dbed6 /src/ClientHandle.cpp | |
parent | Merge pull request #1555 from mc-server/c++11 (diff) | |
download | cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.gz cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.bz2 cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.lz cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.xz cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.tar.zst cuberite-3c3cb198f33fd55b9cb20188cc42034b21660d21.zip |
Diffstat (limited to '')
-rw-r--r-- | src/ClientHandle.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index d246f6da2..c4a620565 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -38,6 +38,11 @@ /** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */ #define MAX_BLOCK_CHANGE_INTERACTIONS 20 +/** The interval for sending pings to clients. +Vanilla sends one ping every 1 second. */ +static const std::chrono::milliseconds PING_TIME_MS = std::chrono::milliseconds(1000); + + @@ -86,7 +91,7 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : s_ClientCount++; // Not protected by CS because clients are always constructed from the same thread m_UniqueID = s_ClientCount; - m_LastPingTime = std::chrono::steady_clock::now(); + m_PingStartTime = std::chrono::steady_clock::now(); LOGD("New ClientHandle created at %p", this); } @@ -384,7 +389,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, // Delay the first ping until the client "settles down" // This should fix #889, "BadCast exception, cannot convert bit to fm" error in client - m_LastPingTime = std::chrono::steady_clock::now() + std::chrono::seconds(3); // Send the first KeepAlive packet in 3 seconds + m_PingStartTime = std::chrono::steady_clock::now() + std::chrono::seconds(3); // Send the first KeepAlive packet in 3 seconds cRoot::Get()->GetPluginManager()->CallHookPlayerSpawned(*m_Player); } @@ -1990,12 +1995,11 @@ void cClientHandle::Tick(float a_Dt) // Send a ping packet: if (m_State == csPlaying) { - if ((m_LastPingTime + cClientHandle::PING_TIME_MS <= std::chrono::steady_clock::now())) + if ((m_PingStartTime + PING_TIME_MS <= std::chrono::steady_clock::now())) { m_PingID++; m_PingStartTime = std::chrono::steady_clock::now(); m_Protocol->SendKeepAlive(m_PingID); - m_LastPingTime = m_PingStartTime; } } |