view Platforms/Wasm/WasmWebService.h @ 249:54c7284b0eff am-2

merged useful changes from branch am
author am@osimis.io
date Mon, 02 Jul 2018 12:45:40 +0200
parents ddbb339ed4cf
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()
    {
    }
  };
}