annotate Platforms/Wasm/WasmWebService.h @ 1221:e2435a524029

merge
author Alain Mazy <alain@mazy.be>
date Sat, 07 Dec 2019 17:47:35 +0100
parents c35e98d22764
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
1 #pragma once
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
2
732
c35e98d22764 move Deprecated classes to a separate folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 726
diff changeset
3 #include "../../Framework/Deprecated/Toolbox/BaseWebService.h"
253
8ff70c04c6df IObservable/IObserver now working in WASM too
am@osimis.io
parents: 240
diff changeset
4 #include <Core/OrthancException.h>
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
5
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
6 namespace Deprecated
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
7 {
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
8 class WasmWebService : public BaseWebService
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
9 {
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
10 private:
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
11 static OrthancStone::MessageBroker *broker_;
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
12
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
13 // Private constructor => Singleton design pattern
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
14 WasmWebService(OrthancStone::MessageBroker &broker) : BaseWebService(broker)
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
15 {
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
16 }
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
17
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
18 public:
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
19 static WasmWebService &GetInstance()
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
20 {
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
21 if (broker_ == NULL)
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
22 {
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
23 printf("WasmWebService::GetInstance(): broker not initialized\n");
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
24 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
25 }
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
26 static WasmWebService instance(*broker_);
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
27 return instance;
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
28 }
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
29
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
30 static void SetBroker(OrthancStone::MessageBroker &broker)
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
31 {
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
32 broker_ = &broker;
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
33 }
253
8ff70c04c6df IObservable/IObserver now working in WASM too
am@osimis.io
parents: 240
diff changeset
34
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
35 virtual void PostAsync(const std::string &uri,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
36 const HttpHeaders &headers,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
37 const std::string &body,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
38 Orthanc::IDynamicObject *payload,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
39 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
40 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable = NULL,
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
41 unsigned int timeoutInSeconds = 60);
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
42
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
43 virtual void DeleteAsync(const std::string &uri,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
44 const HttpHeaders &headers,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
45 Orthanc::IDynamicObject *payload,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
46 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
47 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable = NULL,
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
48 unsigned int timeoutInSeconds = 60);
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
49
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
50 protected:
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
51 virtual void GetAsyncInternal(const std::string &uri,
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
52 const HttpHeaders &headers,
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
53 Orthanc::IDynamicObject *payload,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
54 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
55 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable = NULL,
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
56 unsigned int timeoutInSeconds = 60);
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
57
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
58 virtual void NotifyHttpSuccessLater(boost::shared_ptr<BaseWebService::CachedHttpRequestSuccessMessage> cachedHttpMessage,
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
59 Orthanc::IDynamicObject *payload, // takes ownership
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
60 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallback);
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 431
diff changeset
61 };
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 435
diff changeset
62 } // namespace Deprecated