added better handling of network connections:

- only listen for new clients on a server if an open slot exists (unconnected)
- for both server and client we wait a max of 10 seconds to receive a proper intro packet or we disconnect (could have connected to / from a non glest application using the same port)
This commit is contained in:
Mark Vejvoda
2010-05-12 15:25:56 +00:00
parent d064b52418
commit 319b672e20
11 changed files with 152 additions and 52 deletions

View File

@@ -602,7 +602,6 @@ void ServerInterface::broadcastMessageToConnectedClients(const NetworkMessage* n
void ServerInterface::updateListen()
{
int openSlotCount= 0;
for(int i= 0; i<GameConstants::maxPlayers; ++i)
{
if(slots[i] != NULL && slots[i]->isConnected() == false)
@@ -614,6 +613,20 @@ void ServerInterface::updateListen()
serverSocket.listen(openSlotCount);
}
int ServerInterface::getOpenSlotCount() {
int openSlotCount= 0;
for(int i= 0; i<GameConstants::maxPlayers; ++i)
{
if(slots[i] != NULL && slots[i]->isConnected() == false)
{
++openSlotCount;
}
}
return openSlotCount;
}
void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck)
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck);