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

Method CloseConnection

src/network/network_client.cpp:117–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117NetworkRecvStatus 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.

Callers 1

ClientErrorMethod · 0.95

Calls 5

CSleepFunction · 0.85
IsPendingDeletionMethod · 0.80
HasClientQuitMethod · 0.80
SendPacketsMethod · 0.80
DeferDeletionMethod · 0.80

Tested by

no test coverage detected