Mercurial > hg > orthanc-stone
annotate Deprecated/Platforms/Wasm/WasmWebService.cpp @ 1489:6e43cac7833c
Added public method to update canvas pixel size from CSS size
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 23 Jun 2020 15:41:52 +0200 |
parents | 828a9b4ee1b7 |
children |
rev | line source |
---|---|
1458
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
1 /** |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
2 * Stone of Orthanc |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
6 * |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
10 * the License, or (at your option) any later version. |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
11 * |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
15 * Affero General Public License for more details. |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
16 * |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
19 **/ |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
20 |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1400
diff
changeset
|
21 |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
22 #include "WasmWebService.h" |
257 | 23 #include "json/value.h" |
24 #include "json/writer.h" | |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
25 #include <emscripten/emscripten.h> |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
26 #include <boost/shared_ptr.hpp> |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
27 |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
28 struct CachedSuccessNotification |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
29 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
30 boost::shared_ptr<Deprecated::BaseWebService::CachedHttpRequestSuccessMessage> cachedMessage; |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
940
diff
changeset
|
31 std::unique_ptr<Orthanc::IDynamicObject> payload; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
32 OrthancStone::MessageHandler<Deprecated::IWebService::HttpRequestSuccessMessage>* successCallback; |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
33 }; |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
34 |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
35 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
36 #ifdef __cplusplus |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
37 extern "C" { |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
38 #endif |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
39 |
303 | 40 extern void WasmWebService_GetAsync(void* callableSuccess, |
41 void* callableFailure, | |
42 const char* uri, | |
43 const char* headersInJsonString, | |
309 | 44 void* payload, |
45 unsigned int timeoutInSeconds); | |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
46 |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
47 extern void WasmWebService_ScheduleLaterCachedSuccessNotification(void* brol); |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
48 |
303 | 49 extern void WasmWebService_PostAsync(void* callableSuccess, |
50 void* callableFailure, | |
51 const char* uri, | |
52 const char* headersInJsonString, | |
53 const void* body, | |
54 size_t bodySize, | |
309 | 55 void* payload, |
56 unsigned int timeoutInSeconds); | |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
57 |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
58 extern void WasmWebService_DeleteAsync(void* callableSuccess, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
59 void* callableFailure, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
60 const char* uri, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
61 const char* headersInJsonString, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
62 void* payload, |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
63 unsigned int timeoutInSeconds); |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
64 |
303 | 65 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyError(void* failureCallable, |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
66 const char* uri, |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
67 unsigned int httpStatus, |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
68 void* payload) |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
69 { |
441
56ddca73396c
allow null callbacks for HTTP requests
Alain Mazy <alain@mazy.be>
parents:
435
diff
changeset
|
70 if (failureCallable != NULL) |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
71 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
72 reinterpret_cast<OrthancStone::MessageHandler<Deprecated::IWebService::HttpRequestErrorMessage>*>(failureCallable)-> |
940
861c080ef47b
handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents:
726
diff
changeset
|
73 Apply(Deprecated::IWebService::HttpRequestErrorMessage(uri, static_cast<Orthanc::HttpStatus>(httpStatus), reinterpret_cast<Orthanc::IDynamicObject*>(payload))); |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
74 } |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
75 } |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
76 |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
77 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyCachedSuccess(void* notification_) |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
78 { |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
79 // notification has been allocated in C++ and passed to JS. It must be deleted by this method |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
940
diff
changeset
|
80 std::unique_ptr<CachedSuccessNotification> notification(reinterpret_cast<CachedSuccessNotification*>(notification_)); |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
81 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
82 notification->successCallback->Apply(Deprecated::IWebService::HttpRequestSuccessMessage( |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
83 notification->cachedMessage->GetUri(), |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
84 notification->cachedMessage->GetAnswer(), |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
85 notification->cachedMessage->GetAnswerSize(), |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
86 notification->cachedMessage->GetAnswerHttpHeaders(), |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
87 notification->payload.get() |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
88 )); |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
89 } |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
90 |
303 | 91 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifySuccess(void* successCallable, |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
92 const char* uri, |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
93 const void* body, |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
94 size_t bodySize, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
95 const char* answerHeaders, |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
96 void* payload) |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
97 { |
441
56ddca73396c
allow null callbacks for HTTP requests
Alain Mazy <alain@mazy.be>
parents:
435
diff
changeset
|
98 if (successCallable != NULL) |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
99 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
100 Deprecated::IWebService::HttpHeaders headers; |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
101 |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
102 // TODO - Parse "answerHeaders" |
450 | 103 //printf("TODO: parse headers [%s]\n", answerHeaders); |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
104 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
105 reinterpret_cast<OrthancStone::MessageHandler<Deprecated::IWebService::HttpRequestSuccessMessage>*>(successCallable)-> |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
106 Apply(Deprecated::IWebService::HttpRequestSuccessMessage(uri, body, bodySize, headers, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
107 reinterpret_cast<Orthanc::IDynamicObject*>(payload))); |
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
108 } |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
109 } |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
110 |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
111 #ifdef __cplusplus |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
112 } |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
113 #endif |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
114 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
115 |
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
116 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
117 namespace Deprecated |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
118 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
119 OrthancStone::MessageBroker* WasmWebService::broker_ = NULL; |
253 | 120 |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
121 void ToJsonString(std::string& output, const IWebService::HttpHeaders& headers) |
257 | 122 { |
123 Json::Value jsonHeaders; | |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
124 for (IWebService::HttpHeaders::const_iterator it = headers.begin(); it != headers.end(); it++ ) |
257 | 125 { |
126 jsonHeaders[it->first] = it->second; | |
127 } | |
128 | |
129 Json::StreamWriterBuilder builder; | |
130 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter()); | |
131 std::ostringstream outputStr; | |
132 | |
133 writer->write(jsonHeaders, &outputStr); | |
134 output = outputStr.str(); | |
135 } | |
136 | |
303 | 137 void WasmWebService::PostAsync(const std::string& relativeUri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
138 const HttpHeaders& headers, |
309 | 139 const std::string& body, |
140 Orthanc::IDynamicObject* payload, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
141 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
142 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable, |
309 | 143 unsigned int timeoutInSeconds) |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
144 { |
257 | 145 std::string headersInJsonString; |
146 ToJsonString(headersInJsonString, headers); | |
418 | 147 WasmWebService_PostAsync(successCallable, failureCallable, relativeUri.c_str(), headersInJsonString.c_str(), |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
148 body.c_str(), body.size(), payload, timeoutInSeconds); |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
149 } |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
150 |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
151 void WasmWebService::DeleteAsync(const std::string& relativeUri, |
417
aee3d7941c9b
preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
152 const HttpHeaders& headers, |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
153 Orthanc::IDynamicObject* payload, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
154 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
155 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable, |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
156 unsigned int timeoutInSeconds) |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
157 { |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
158 std::string headersInJsonString; |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
159 ToJsonString(headersInJsonString, headers); |
418 | 160 WasmWebService_DeleteAsync(successCallable, failureCallable, relativeUri.c_str(), headersInJsonString.c_str(), |
315
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
161 payload, timeoutInSeconds); |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
162 } |
aad37d0b6407
Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents:
309
diff
changeset
|
163 |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
418
diff
changeset
|
164 void WasmWebService::GetAsyncInternal(const std::string &relativeUri, |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
418
diff
changeset
|
165 const HttpHeaders &headers, |
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
418
diff
changeset
|
166 Orthanc::IDynamicObject *payload, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
167 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable, |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
168 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable, |
434
3a8bcc45c221
moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents:
418
diff
changeset
|
169 unsigned int timeoutInSeconds) |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
170 { |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
171 std::string headersInJsonString; |
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
172 ToJsonString(headersInJsonString, headers); |
418 | 173 WasmWebService_GetAsync(successCallable, failureCallable, relativeUri.c_str(), |
174 headersInJsonString.c_str(), payload, timeoutInSeconds); | |
299
3897f9f28cfa
backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents:
257
diff
changeset
|
175 } |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
176 |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
177 void WasmWebService::NotifyHttpSuccessLater(boost::shared_ptr<BaseWebService::CachedHttpRequestSuccessMessage> cachedMessage, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
178 Orthanc::IDynamicObject* payload, // takes ownership |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
450
diff
changeset
|
179 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback) |
435
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
180 { |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
181 CachedSuccessNotification* notification = new CachedSuccessNotification(); // allocated on the heap, it will be passed to JS and deleted when coming back to C++ |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
182 notification->cachedMessage = cachedMessage; |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
183 notification->payload.reset(payload); |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
184 notification->successCallback = successCallback; |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
185 |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
186 WasmWebService_ScheduleLaterCachedSuccessNotification(notification); |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
187 } |
e641d3978856
WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents:
434
diff
changeset
|
188 |
221
d7b2590744f8
wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff
changeset
|
189 } |