annotate Platforms/Wasm/WasmWebService.cpp @ 1313:f30905f5d246 broker

Added support for OnGenericSdlEvent to GuiAdapter. This makes it possible to piggyback app-specific logic to special events (here, to support the Viewport refresh events)
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 16 Mar 2020 11:12:39 +0100
parents 8a0a62189f46
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 #include "WasmWebService.h"
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
2 #include "json/value.h"
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
3 #include "json/writer.h"
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
4 #include <emscripten/emscripten.h>
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
5 #include <boost/shared_ptr.hpp>
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
6
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
7 struct CachedSuccessNotification
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
8 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
9 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
10 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
11 OrthancStone::MessageHandler<Deprecated::IWebService::HttpRequestSuccessMessage>* successCallback;
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
12 };
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
13
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
14
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
15 #ifdef __cplusplus
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
16 extern "C" {
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
17 #endif
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
18
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
19 extern void WasmWebService_GetAsync(void* callableSuccess,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
20 void* callableFailure,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
21 const char* uri,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
22 const char* headersInJsonString,
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
23 void* payload,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
24 unsigned int timeoutInSeconds);
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
25
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
26 extern void WasmWebService_ScheduleLaterCachedSuccessNotification(void* brol);
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
27
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
28 extern void WasmWebService_PostAsync(void* callableSuccess,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
29 void* callableFailure,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
30 const char* uri,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
31 const char* headersInJsonString,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
32 const void* body,
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
33 size_t bodySize,
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
34 void* payload,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
35 unsigned int timeoutInSeconds);
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
36
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
37 extern void WasmWebService_DeleteAsync(void* callableSuccess,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
38 void* callableFailure,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
39 const char* uri,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
40 const char* headersInJsonString,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
41 void* payload,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
42 unsigned int timeoutInSeconds);
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
43
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
44 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
45 const char* uri,
940
861c080ef47b handling httpStatus in WebService error messages
Alain Mazy <alain@mazy.be>
parents: 726
diff changeset
46 unsigned int httpStatus,
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
47 void* payload)
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
48 {
441
56ddca73396c allow null callbacks for HTTP requests
Alain Mazy <alain@mazy.be>
parents: 435
diff changeset
49 if (failureCallable != NULL)
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
50 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
51 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
52 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
53 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
54 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
55
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
56 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyCachedSuccess(void* notification_)
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
57 {
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
58 // 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
59 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
60
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
61 notification->successCallback->Apply(Deprecated::IWebService::HttpRequestSuccessMessage(
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
62 notification->cachedMessage->GetUri(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
63 notification->cachedMessage->GetAnswer(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
64 notification->cachedMessage->GetAnswerSize(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
65 notification->cachedMessage->GetAnswerHttpHeaders(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
66 notification->payload.get()
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
67 ));
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
68 }
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
69
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
70 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
71 const char* uri,
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
72 const void* body,
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
73 size_t bodySize,
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
74 const char* answerHeaders,
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
75 void* payload)
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
76 {
441
56ddca73396c allow null callbacks for HTTP requests
Alain Mazy <alain@mazy.be>
parents: 435
diff changeset
77 if (successCallable != NULL)
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
78 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
79 Deprecated::IWebService::HttpHeaders headers;
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
80
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
81 // TODO - Parse "answerHeaders"
450
a04f08baba27 removed log
Alain Mazy <alain@mazy.be>
parents: 441
diff changeset
82 //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
83
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
84 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
85 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
86 reinterpret_cast<Orthanc::IDynamicObject*>(payload)));
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
87 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
88 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
89
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
90 #ifdef __cplusplus
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
91 }
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
92 #endif
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
93
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
94
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
95
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
96 namespace Deprecated
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
97 {
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
98 OrthancStone::MessageBroker* WasmWebService::broker_ = NULL;
253
8ff70c04c6df IObservable/IObserver now working in WASM too
am@osimis.io
parents: 240
diff changeset
99
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
100 void ToJsonString(std::string& output, const IWebService::HttpHeaders& headers)
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
101 {
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
102 Json::Value jsonHeaders;
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
103 for (IWebService::HttpHeaders::const_iterator it = headers.begin(); it != headers.end(); it++ )
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
104 {
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
105 jsonHeaders[it->first] = it->second;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
106 }
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
107
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
108 Json::StreamWriterBuilder builder;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
109 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
110 std::ostringstream outputStr;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
111
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
112 writer->write(jsonHeaders, &outputStr);
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
113 output = outputStr.str();
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
114 }
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
115
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
116 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
117 const HttpHeaders& headers,
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
118 const std::string& body,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
119 Orthanc::IDynamicObject* payload,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
120 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
121 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable,
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
122 unsigned int timeoutInSeconds)
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
123 {
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
124 std::string headersInJsonString;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
125 ToJsonString(headersInJsonString, headers);
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
126 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
127 body.c_str(), body.size(), payload, timeoutInSeconds);
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
128 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
129
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
130 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
131 const HttpHeaders& headers,
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
132 Orthanc::IDynamicObject* payload,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
133 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
134 OrthancStone::MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable,
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
135 unsigned int timeoutInSeconds)
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
136 {
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
137 std::string headersInJsonString;
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
138 ToJsonString(headersInJsonString, headers);
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
139 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
140 payload, timeoutInSeconds);
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
141 }
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
142
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
143 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
144 const HttpHeaders &headers,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
145 Orthanc::IDynamicObject *payload,
726
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
146 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
147 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
148 unsigned int timeoutInSeconds)
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
149 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
150 std::string headersInJsonString;
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
151 ToJsonString(headersInJsonString, headers);
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
152 WasmWebService_GetAsync(successCallable, failureCallable, relativeUri.c_str(),
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
153 headersInJsonString.c_str(), payload, timeoutInSeconds);
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
154 }
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
155
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
156 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
157 Orthanc::IDynamicObject* payload, // takes ownership
4f2416d519b4 moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 450
diff changeset
158 OrthancStone::MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback)
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
159 {
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
160 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
161 notification->cachedMessage = cachedMessage;
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
162 notification->payload.reset(payload);
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
163 notification->successCallback = successCallback;
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
164
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
165 WasmWebService_ScheduleLaterCachedSuccessNotification(notification);
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
166 }
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
167
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
168 }