1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

make server a static lib, run it in a separate thread

issues to solve:
- dynamic_cast error 2: One or more of the following type_info's has hidden visibility or is defined in more than one translation unit. They should all have public visibility. 13CPackForLobby, 20LobbyClientConnected, 20LobbyClientConnected.
- error setting socket option: set_option: No buffer space available
This commit is contained in:
Andrey Filipenkov
2021-03-05 19:26:35 +03:00
parent d6f8e4328c
commit 2e18299897
12 changed files with 88 additions and 20 deletions

View File

@ -24,7 +24,8 @@
#ifdef VCMI_ANDROID
#include "../lib/CAndroidVMHelper.h"
#elif defined(VCMI_IOS)
//TODO
#include "../server/CVCMIServer.h"
// todo ios
#else
#include "../lib/Interprocess.h"
#endif
@ -184,7 +185,18 @@ void CServerHandler::startLocalServerAndConnect()
envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true);
}
#elif defined(VCMI_IOS)
// TODO
// todo ios: hide keyboard
logNetwork->info("[ios] create server thread");
boost::condition_variable cond;
threadRunLocalServer = std::make_shared<boost::thread>([&cond, this] {
setThreadName("CVCMIServer");
CVCMIServer::create(&cond);
// todo ios copypaste
threadRunLocalServer.reset();
CSH->campaignServerRestartLock.setn(false);
});
// threadRunLocalServer->detach();
logNetwork->info("[ios] detach server thread");
#else
threadRunLocalServer = std::make_shared<boost::thread>(&CServerHandler::threadRunServer, this); //runs server executable;
#endif
@ -202,7 +214,14 @@ void CServerHandler::startLocalServerAndConnect()
logNetwork->info("waiting for server finished...");
androidTestServerReadyFlag = false;
#elif defined(VCMI_IOS)
//TODO
// todo ios
{
boost::mutex m;
boost::unique_lock<boost::mutex> lock{m};
logNetwork->info("[ios] wait for server");
cond.wait(lock);
logNetwork->info("[ios] server ready");
}
#else
if(shm)
shm->sr->waitTillReady();