| 136 | |
| 137 | |
| 138 | bool CClientTCPSocket::CheckTimeOut() |
| 139 | { |
| 140 | // 0.42x |
| 141 | uint64 uTimeout = GetTimeOut(); |
| 142 | if (m_client) { |
| 143 | |
| 144 | if (m_client->GetKadState() == KS_CONNECTED_BUDDY) { |
| 145 | //We originally ignored the timeout here for buddies. |
| 146 | //This was a stupid idea on my part. There is now a ping/pong system |
| 147 | //for buddies. This ping/pong system now prevents timeouts. |
| 148 | //This release will allow lowID clients with KadVersion 0 to remain connected. |
| 149 | //But a soon future version needs to allow these older clients to time out to prevent dead connections from continuing. |
| 150 | //JOHNTODO: Don't forget to remove backward support in a future release. |
| 151 | if ( m_client->GetKadVersion() == 0 ) { |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | uTimeout += MIN2MS(15); |
| 156 | } |
| 157 | |
| 158 | if (m_client->GetChatState() != MS_NONE) { |
| 159 | uTimeout += CONNECTION_TIMEOUT; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | uint64 now = ::GetTickCount64(); |
| 164 | if (now - timeout_timer > uTimeout){ |
| 165 | timeout_timer = now; |
| 166 | Disconnect("Timeout"); |
| 167 | return true; |
| 168 | } |
| 169 | |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | |
| 174 | void CClientTCPSocket::SetClient(CUpDownClient* pClient) |
no test coverage detected