made JsonApiServer an singleton through static method instance()

This commit is contained in:
csoler 2019-11-12 22:32:18 +01:00
parent 3b45fc5199
commit d19d1685de
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
9 changed files with 129 additions and 95 deletions

View file

@ -91,7 +91,7 @@ void RsServer::rsGlobalShutDown()
mNetMgr->shutdown(); /* Handles UPnP */
#ifdef RS_JSONAPI
if(jsonApiServer) jsonApiServer->shutdown();
JsonApiServer::instance().shutdown();
#endif
rsAutoProxyMonitor::instance()->stopAllRSShutdown();

View file

@ -410,10 +410,8 @@ int RsInit::InitRetroShare(const RsConfigOptions& conf)
#ifdef RS_JSONAPI
if(rsInitConfig->jsonApiPort)
{
jsonApiServer = new JsonApiServer( rsInitConfig->jsonApiPort, rsInitConfig->jsonApiBindAddress );
jsonApiServer->start("JSON API Server");
}
JsonApiServer::instance().start(rsInitConfig->jsonApiPort, rsInitConfig->jsonApiBindAddress);
#endif // ifdef RS_JSONAPI
return RS_INIT_OK;
@ -1214,14 +1212,7 @@ int RsServer::StartupRetroShare()
//
mPluginsManager->loadPlugins(programatically_inserted_plugins) ;
#ifdef RS_JSONAPI
if(jsonApiServer) // JsonApiServer may be disabled at runtime
{
mConfigMgr->addConfiguration("jsonApi.cfg", jsonApiServer);
RsFileHash dummyHash;
jsonApiServer->loadConfiguration(dummyHash);
}
#endif
JsonApiServer::setConfigMgr(mConfigMgr);
/**** Reputation system ****/
@ -1230,7 +1221,7 @@ int RsServer::StartupRetroShare()
#ifdef RS_ENABLE_GXS
std::string currGxsDir = RsAccounts::AccountDirectory() + "/gxs";
std::string currGxsDir = RsAccounts::AccountDirectory() + "/gxs";
RsDirUtil::checkCreateDirectory(currGxsDir);
RsNxsNetMgr* nxsMgr = new RsNxsNetMgrImpl(serviceCtrl);