(svn r20929) -Codechange: make NetworkCloseClient a class method

This commit is contained in:
rubidium
2010-10-15 18:42:52 +00:00
parent 8f9ae44a67
commit 7ba07d9573
8 changed files with 88 additions and 70 deletions

View File

@@ -51,6 +51,28 @@ ClientNetworkGameSocketHandler::~ClientNetworkGameSocketHandler()
ClientNetworkGameSocketHandler::my_client = NULL;
}
NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvStatus status)
{
assert(status != NETWORK_RECV_STATUS_OKAY);
/*
* Sending a message just before leaving the game calls cs->Send_Packets.
* This might invoke this function, which means that when we close the
* connection after cs->Send_Packets we will close an already closed
* connection. This handles that case gracefully without having to make
* that code any more complex or more aware of the validity of the socket.
*/
if (this->sock == INVALID_SOCKET) return status;
DEBUG(net, 1, "Closed client connection %d", this->client_id);
this->Send_Packets(true);
delete this->GetInfo();
delete this;
return status;
}
/** Our client's connection. */
ClientNetworkGameSocketHandler * ClientNetworkGameSocketHandler::my_client = NULL;