| 115 | } |
| 116 | |
| 117 | NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvStatus status) |
| 118 | { |
| 119 | assert(status != NETWORK_RECV_STATUS_OKAY); |
| 120 | if (this->IsPendingDeletion()) return status; |
| 121 | |
| 122 | assert(this->sock != INVALID_SOCKET); |
| 123 | |
| 124 | if (!this->HasClientQuit()) { |
| 125 | Debug(net, 3, "Closed client connection {}", this->client_id); |
| 126 | |
| 127 | this->SendPackets(true); |
| 128 | |
| 129 | /* Wait a number of ticks so our leave message can reach the server. |
| 130 | * This is especially needed for Windows servers as they seem to get |
| 131 | * the "socket is closed" message before receiving our leave message, |
| 132 | * which would trigger the server to close the connection as well. */ |
| 133 | CSleep(3 * MILLISECONDS_PER_TICK); |
| 134 | } |
| 135 | |
| 136 | this->DeferDeletion(); |
| 137 | |
| 138 | return status; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Handle an error coming from the client side. |
no test coverage detected