MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CheckConnection

Method CheckConnection

src/network/network_query.cpp:40–52  ·  view source on GitHub ↗

* Check the connection's state, i.e. is the connection still up? */

Source from the content-addressed store, hash-verified

38 * Check the connection's state, i.e. is the connection still up?
39 */
40bool QueryNetworkGameSocketHandler::CheckConnection()
41{
42 std::chrono::steady_clock::duration lag = std::chrono::steady_clock::now() - this->last_packet;
43
44 /* If there was no response in 5 seconds, terminate the query. */
45 if (lag > std::chrono::seconds(5)) {
46 Debug(net, 0, "Timeout while waiting for response from {}", this->connection_string);
47 this->CloseConnection(NETWORK_RECV_STATUS_CONNECTION_LOST);
48 return false;
49 }
50
51 return true;
52}
53
54/**
55 * Check whether we received/can send some data from/to the server and

Callers 1

SendReceiveMethod · 0.45

Calls 2

CloseConnectionMethod · 0.95
nowClass · 0.85

Tested by

no test coverage detected