Mercurial > hg > orthanc-stone
annotate Platforms/Wasm/WasmWebService.h @ 419:d638d5721f1c
replace deprecated writeStringToMemory by stringToUTF8
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 15 Nov 2018 18:41:50 +0100 |
parents | c23df8b3433b |
children | 26b90b110719 |
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 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
3 #include <Framework/Toolbox/IWebService.h> |
253 | 4 #include <Core/OrthancException.h> |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
5 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
6 namespace OrthancStone |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
7 { |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
8 class WasmWebService : public IWebService |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
9 { |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
10 private: |
253 | 11 static MessageBroker* broker_; |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
12 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
13 // Private constructor => Singleton design pattern |
253 | 14 WasmWebService(MessageBroker& broker) : |
418 | 15 IWebService(broker) |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
16 { |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
17 } |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
18 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
19 public: |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
20 static WasmWebService& GetInstance() |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
21 { |
253 | 22 if (broker_ == NULL) |
23 { | |
255 | 24 printf("WasmWebService::GetInstance(): broker not initialized\n"); |
253 | 25 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
26 } | |
27 static WasmWebService instance(*broker_); | |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
28 return instance; |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
29 } |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
30 |
253 | 31 static void SetBroker(MessageBroker& broker) |
32 { | |
33 broker_ = &broker; | |
34 } | |
35 | |
303 | 36 virtual void GetAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
37 const HttpHeaders& headers, |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
38 Orthanc::IDynamicObject* payload, |
303 | 39 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, |
309 | 40 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable = NULL, |
41 unsigned int timeoutInSeconds = 60); | |
303 | 42 |
43 virtual void PostAsync(const std::string& uri, | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
44 const HttpHeaders& headers, |
303 | 45 const std::string& body, |
46 Orthanc::IDynamicObject* payload, | |
47 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, | |
309 | 48 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable = NULL, |
49 unsigned int timeoutInSeconds = 60); | |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
50 |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
51 virtual void DeleteAsync(const std::string& uri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
52 const HttpHeaders& headers, |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
53 Orthanc::IDynamicObject* payload, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
54 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
55 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable = NULL, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
56 unsigned int timeoutInSeconds = 60); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
57 |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
58 virtual void Start() |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
59 { |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
60 } |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
61 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
62 virtual void Stop() |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
63 { |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
64 } |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
65 }; |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
66 } |