Codechange: [Network] replace _realtime_tick with std::chrono
(cherry picked from commit 53c28a8ec9
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
729df75d3e
commit
d4f208d9c1
@@ -718,9 +718,9 @@ ClientNetworkContentSocketHandler::ClientNetworkContentSocketHandler() :
|
||||
http_response_index(-2),
|
||||
curFile(nullptr),
|
||||
curInfo(nullptr),
|
||||
isConnecting(false),
|
||||
lastActivity(_realtime_tick)
|
||||
isConnecting(false)
|
||||
{
|
||||
this->lastActivity = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
/** Clear up the mess ;) */
|
||||
@@ -750,7 +750,7 @@ public:
|
||||
void OnConnect(SOCKET s) override
|
||||
{
|
||||
assert(_network_content_client.sock == INVALID_SOCKET);
|
||||
_network_content_client.lastActivity = _realtime_tick;
|
||||
_network_content_client.lastActivity = std::chrono::steady_clock::now();
|
||||
_network_content_client.isConnecting = false;
|
||||
_network_content_client.sock = s;
|
||||
_network_content_client.Reopen();
|
||||
@@ -787,7 +787,7 @@ void ClientNetworkContentSocketHandler::SendReceive()
|
||||
{
|
||||
if (this->sock == INVALID_SOCKET || this->isConnecting) return;
|
||||
|
||||
if (this->lastActivity + IDLE_TIMEOUT < _realtime_tick) {
|
||||
if (std::chrono::steady_clock::now() > this->lastActivity + IDLE_TIMEOUT) {
|
||||
this->Close();
|
||||
return;
|
||||
}
|
||||
@@ -795,7 +795,7 @@ void ClientNetworkContentSocketHandler::SendReceive()
|
||||
if (this->CanSendReceive()) {
|
||||
if (this->ReceivePackets()) {
|
||||
/* Only update activity once a packet is received, instead of every time we try it. */
|
||||
this->lastActivity = _realtime_tick;
|
||||
this->lastActivity = std::chrono::steady_clock::now();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user