Fixed server termination issue.

This commit is contained in:
lotodore
2007-10-02 18:58:54 +00:00
parent 73c90d4106
commit 351d32659f
3 changed files with 14 additions and 7 deletions
+2 -1
View File
@@ -93,7 +93,8 @@ main(int argc, char *argv[])
myServerGuiInterface->getSession().startNetworkServer(); myServerGuiInterface->getSession().startNetworkServer();
while (!g_pokerthTerminate) while (!g_pokerthTerminate)
{ {
myServerGuiInterface->getSession().waitForNetworkServer(100); if (myServerGuiInterface->getSession().waitForNetworkServer(100))
g_pokerthTerminate = true;
} }
myServerGuiInterface->getSession().terminateNetworkServer(); myServerGuiInterface->getSession().terminateNetworkServer();
+11 -5
View File
@@ -235,15 +235,21 @@ void Session::terminateNetworkServer()
myNetServer = 0; myNetServer = 0;
} }
void Session::waitForNetworkServer(unsigned timeoutMsec) bool Session::waitForNetworkServer(unsigned timeoutMsec)
{ {
bool retVal = false;
if (!myNetServer) if (!myNetServer)
return; // already terminated retVal = true; // already terminated
if (myNetServer->Join(timeoutMsec)) else
{ {
delete myNetServer; if (myNetServer->Join(timeoutMsec))
myNetServer = 0; {
delete myNetServer;
myNetServer = 0;
retVal = true;
}
} }
return retVal;
} }
void Session::startIrcClient() void Session::startIrcClient()
+1 -1
View File
@@ -60,7 +60,7 @@ public:
void sendLeaveCurrentGame(); void sendLeaveCurrentGame();
void sendStartEvent(bool fillUpWithCpuPlayers); void sendStartEvent(bool fillUpWithCpuPlayers);
void terminateNetworkServer(); void terminateNetworkServer();
void waitForNetworkServer(unsigned timeoutMsec); bool waitForNetworkServer(unsigned timeoutMsec);
void startIrcClient(); void startIrcClient();
void sendIrcChatMessage(const std::string &message); void sendIrcChatMessage(const std::string &message);