cancel connection process when server is unreachable. closes #1975

This commit is contained in:
oy 2019-01-17 17:52:33 +01:00
parent fbc61d22fc
commit 9d08f62558

View file

@ -196,6 +196,7 @@ int CNetConnection::Connect(NETADDR *pAddr)
// init connection
Reset();
m_LastRecvTime = time_get();
m_PeerAddr = *pAddr;
m_PeerToken = NET_TOKEN_NONE;
SetToken(GenerateToken(pAddr));
@ -378,6 +379,11 @@ int CNetConnection::Update()
m_State = NET_CONNSTATE_ERROR;
SetError("Timeout");
}
else if(State() == NET_CONNSTATE_TOKEN && (Now - m_LastRecvTime) > time_freq() * 5)
{
m_State = NET_CONNSTATE_ERROR;
SetError("Unable to connect to the server");
}
// fix resends
if(m_Buffer.First())