view Platforms/Wasm/WasmWebService.h @ 240:ddbb339ed4cf am

orthancBaseUrl is now configurable
author am@osimis.io
date Wed, 20 Jun 2018 09:43:36 +0200
parents b4642964c355
children 3d523c9a8f0d 8ff70c04c6df
line wrap: on
line source

#pragma once

#include <Framework/Toolbox/IWebService.h>

namespace OrthancStone
{
  class WasmWebService : public IWebService
  {
  private:
    std::string  base_;

    // Private constructor => Singleton design pattern
    WasmWebService() :
      base_("../../")   // note: this is configurable from the JS code by calling WasmWebService_SetBaseUrl
    {
    }

  public:
    static WasmWebService& GetInstance()
    {
      static WasmWebService instance;
      return instance;
    }

    void SetBaseUrl(const std::string base);

    virtual void ScheduleGetRequest(ICallback& callback,
                                    const std::string& uri,
                                    Orthanc::IDynamicObject* payload);

    virtual void SchedulePostRequest(ICallback& callback,
                                     const std::string& uri,
                                     const std::string& body,
                                     Orthanc::IDynamicObject* payload);

    virtual void Start()
    {
    }
    
    virtual void Stop()
    {
    }
  };
}