mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-29 17:28:41 -04:00
Merge pull request #1774 from G10h4ck/json_api_improvements
JSON API improvements
This commit is contained in:
commit
a9f24c85a0
14 changed files with 530 additions and 153 deletions
|
@ -112,28 +112,41 @@ QString JsonApiPage::helpText() const { return ""; }
|
|||
|
||||
bool JsonApiPage::checkStartJsonApi()
|
||||
{
|
||||
if(!Settings->getJsonApiEnabled())
|
||||
return false;
|
||||
if(!Settings->getJsonApiEnabled()) return false;
|
||||
|
||||
rsJsonApi->setListeningPort(Settings->getJsonApiPort());
|
||||
rsJsonApi->setBindingAddress(Settings->getJsonApiListenAddress().toStdString());
|
||||
rsJsonApi->restart();
|
||||
|
||||
const auto rErr = rsJsonApi->restart();
|
||||
if(rErr == RsJsonApiErrorNum::NOT_A_MACHINE_GUN)
|
||||
{
|
||||
RsDbg() << __PRETTY_FUNCTION__ << " apparently the user is attempting "
|
||||
<< "to restart JSON API service in a burst. Re-scheduling "
|
||||
<< "restart in a while..." << std::endl;
|
||||
RsThread::async([]()
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
rsJsonApi->restart();
|
||||
});
|
||||
}
|
||||
else if(rErr)
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << rErr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*static*/ void JsonApiPage::checkShutdownJsonApi()
|
||||
{
|
||||
if(!rsJsonApi->isRunning()) return;
|
||||
rsJsonApi->fullstop(); // this is a blocks until the thread is terminated.
|
||||
}
|
||||
|
||||
void JsonApiPage::onApplyClicked()
|
||||
{
|
||||
// restart
|
||||
|
||||
checkShutdownJsonApi();
|
||||
checkStartJsonApi();
|
||||
// restart
|
||||
checkStartJsonApi();
|
||||
}
|
||||
|
||||
void JsonApiPage::checkToken(QString s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue