mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-28 16:17:28 -04:00
changed layout of restbed/json/webui so that JsonApi is the only server (with thread functionality in a separate class) and webui is a resource provider
This commit is contained in:
parent
997501a24d
commit
009ed54ce2
8 changed files with 156 additions and 170 deletions
|
@ -136,7 +136,7 @@ void p3WebUI::setHtmlFilesDirectory(const std::string& html_dir)
|
|||
|
||||
int p3WebUI::status() const
|
||||
{
|
||||
if(isRunning())
|
||||
if(rsJsonAPI->status()==RsJsonAPI::JSONAPI_STATUS_RUNNING && rsJsonAPI->hasResourceProvider(this))
|
||||
return WEBUI_STATUS_RUNNING;
|
||||
else
|
||||
return WEBUI_STATUS_NOT_RUNNING;
|
||||
|
@ -153,3 +153,22 @@ void p3WebUI::setUserPassword(const std::string& passwd)
|
|||
std::cerr << "(EE) JsonAPI is not available in this buildof Retroshare! Cannot register a user password for the WebUI" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool p3WebUI::restart()
|
||||
{
|
||||
rsJsonAPI->registerResourceProvider(this);
|
||||
|
||||
return rsJsonAPI->restart();
|
||||
}
|
||||
|
||||
bool p3WebUI::stop()
|
||||
{
|
||||
rsJsonAPI->unregisterResourceProvider(this);
|
||||
|
||||
if(rsJsonAPI->status()==RsJsonAPI::JSONAPI_STATUS_RUNNING)
|
||||
return rsJsonAPI->restart();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,23 +24,26 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
#include "retroshare/rswebui.h"
|
||||
#include "jsonapi/restbedservice.h"
|
||||
#include "jsonapi/jsonapi.h"
|
||||
|
||||
class p3WebUI: public RsWebUI, public RestbedService
|
||||
class p3WebUI: public RsWebUI, public JsonApiResourceProvider
|
||||
{
|
||||
public:
|
||||
p3WebUI(){}
|
||||
virtual ~p3WebUI(){}
|
||||
|
||||
virtual void setHtmlFilesDirectory(const std::string& html_dir) override;
|
||||
// implements RsWebUI
|
||||
|
||||
virtual bool restart() override { return RestbedService::restart();}
|
||||
virtual bool stop() override { return RestbedService::stop();}
|
||||
virtual void setListeningPort(uint16_t port) override { RestbedService::setListeningPort(port) ;}
|
||||
virtual void setBindingAddress(const std::string& address) override { RestbedService::setBindAddress(address) ;}
|
||||
virtual void setHtmlFilesDirectory(const std::string& html_dir) override;
|
||||
virtual void setUserPassword(const std::string& passwd) override;
|
||||
|
||||
virtual int status() const override;
|
||||
virtual bool restart() override ;
|
||||
virtual bool stop() override ;
|
||||
virtual int status() const override;
|
||||
|
||||
// implements JsonApiResourceProvider
|
||||
|
||||
virtual std::string getName() const override { return "Web Interface" ;}
|
||||
virtual std::vector<std::shared_ptr<restbed::Resource> > getResources() const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -398,9 +398,9 @@ int RsInit::InitRetroShare(const RsConfigOptions& conf)
|
|||
RsInfo() << "Allocating jsonAPI server (not launched yet) " << std::endl;
|
||||
JsonApiServer *jas = new JsonApiServer();
|
||||
jas->setListeningPort(conf.jsonApiPort);
|
||||
jas->setBindingAddress(conf.jsonApiBindAddress);
|
||||
jas->setBindAddress(conf.jsonApiBindAddress);
|
||||
|
||||
if(conf.jsonApiPort != NULL)
|
||||
if(conf.jsonApiPort != 0)
|
||||
{
|
||||
RsInfo() << "Launching jsonAPI server on port " << conf.jsonApiPort << std::endl;
|
||||
jas->restart();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue