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:
+15
-1
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user