When creating a network game, a client is also started.

Network errors are handled globally.
Fixed last network thread issue by using a notification queue, should work fine now.
This commit is contained in:
lotodore
2007-03-20 14:05:16 +00:00
parent 7a704c2995
commit 62e72617ba
9 changed files with 172 additions and 100 deletions
+15 -1
View File
@@ -39,6 +39,7 @@ Session::Session(GuiInterface *g)
Session::~Session()
{
terminateNetworkClient();
terminateNetworkServer();
deleteGame();
delete myConfig;
}
@@ -67,6 +68,19 @@ void Session::startNetworkClient(const string &serverAddress, unsigned serverPor
myNetClient->Run();
}
void Session::startNetworkClientForLocalServer()
{
if (myNetClient || !myGui)
return; // TODO: throw exception
myNetClient = new ClientThread(*myGui);
myNetClient->Init(
"localhost",
myConfig->readConfigInt("ServerPort"),
myConfig->readConfigInt("ServerUseIpv6") == 1,
myConfig->readConfigString("ServerPassword"));
myNetClient->Run();
}
void Session::terminateNetworkClient()
{
if (!myNetClient)
@@ -89,7 +103,7 @@ void Session::startNetworkServer()
myNetServer->Init(
myConfig->readConfigInt("ServerPort"),
myConfig->readConfigInt("ServerUseIpv6") == 1,
""); // TODO: use pwd
myConfig->readConfigString("ServerPassword"));
myNetServer->Run();
}