annotate Platforms/Wasm/WasmWebService.cpp @ 435:e641d3978856 am-vsol-upgrade

WasmWebService now using BaseWebService and supporting cache
author am@osimis.io
date Tue, 04 Dec 2018 11:52:43 +0100
parents 3a8bcc45c221
children 56ddca73396c
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 {
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
9 boost::shared_ptr<OrthancStone::BaseWebService::CachedHttpRequestSuccessMessage> cachedMessage;
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
10 std::auto_ptr<Orthanc::IDynamicObject> payload;
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
11 OrthancStone::MessageHandler<OrthancStone::IWebService::HttpRequestSuccessMessage>* successCallback;
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,
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
46 void* payload)
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
47 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
48 if (failureCallable == NULL)
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
49 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
50 throw;
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
51 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
52 else
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
53 {
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
54 reinterpret_cast<OrthancStone::MessageHandler<OrthancStone::IWebService::HttpRequestErrorMessage>*>(failureCallable)->
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
55 Apply(OrthancStone::IWebService::HttpRequestErrorMessage(uri, reinterpret_cast<Orthanc::IDynamicObject*>(payload)));
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
56 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
57 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
58
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
59 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyCachedSuccess(void* notification_)
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
60 {
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
61 // notification has been allocated in C++ and passed to JS. It must be deleted by this method
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
62 std::auto_ptr<CachedSuccessNotification> notification(reinterpret_cast<CachedSuccessNotification*>(notification_));
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
63
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
64 notification->successCallback->Apply(OrthancStone::IWebService::HttpRequestSuccessMessage(
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
65 notification->cachedMessage->GetUri(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
66 notification->cachedMessage->GetAnswer(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
67 notification->cachedMessage->GetAnswerSize(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
68 notification->cachedMessage->GetAnswerHttpHeaders(),
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
69 notification->payload.get()
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
70 ));
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
71 }
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
72
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
73 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
74 const char* uri,
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
75 const void* body,
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
76 size_t bodySize,
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
77 const char* answerHeaders,
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
78 void* payload)
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
79 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
80 if (successCallable == NULL)
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
81 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
82 throw;
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
83 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
84 else
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
85 {
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
86 OrthancStone::IWebService::HttpHeaders headers;
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
87
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
88 // TODO - Parse "answerHeaders"
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
89 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
90
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
91 reinterpret_cast<OrthancStone::MessageHandler<OrthancStone::IWebService::HttpRequestSuccessMessage>*>(successCallable)->
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
92 Apply(OrthancStone::IWebService::HttpRequestSuccessMessage(uri, body, bodySize, headers,
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
93 reinterpret_cast<Orthanc::IDynamicObject*>(payload)));
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
94 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
95 }
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
96
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
97 #ifdef __cplusplus
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
98 }
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
99 #endif
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
100
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
101
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
102
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
103 namespace OrthancStone
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
104 {
253
8ff70c04c6df IObservable/IObserver now working in WASM too
am@osimis.io
parents: 240
diff changeset
105 MessageBroker* WasmWebService::broker_ = NULL;
8ff70c04c6df IObservable/IObserver now working in WASM too
am@osimis.io
parents: 240
diff changeset
106
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
107 void ToJsonString(std::string& output, const IWebService::HttpHeaders& headers)
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
108 {
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
109 Json::Value jsonHeaders;
417
aee3d7941c9b preparing to load images using DICOMweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 315
diff changeset
110 for (IWebService::HttpHeaders::const_iterator it = headers.begin(); it != headers.end(); it++ )
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
111 {
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
112 jsonHeaders[it->first] = it->second;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
113 }
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
114
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
115 Json::StreamWriterBuilder builder;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
116 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
117 std::ostringstream outputStr;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
118
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
119 writer->write(jsonHeaders, &outputStr);
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
120 output = outputStr.str();
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
121 }
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
122
303
ed1a4302154f new messages in wasm too
am@osimis.io
parents: 299
diff changeset
123 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
124 const HttpHeaders& headers,
309
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
125 const std::string& body,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
126 Orthanc::IDynamicObject* payload,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
127 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
128 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable,
14ef1227120f web services: better handling of failures
am@osimis.io
parents: 303
diff changeset
129 unsigned int timeoutInSeconds)
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
130 {
257
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
131 std::string headersInJsonString;
9afafb192180 using PAM
am@osimis.io
parents: 253
diff changeset
132 ToJsonString(headersInJsonString, headers);
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
133 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
134 body.c_str(), body.size(), payload, timeoutInSeconds);
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
135 }
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
136
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
137 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
138 const HttpHeaders& headers,
315
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
139 Orthanc::IDynamicObject* payload,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
140 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallable,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
141 MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallable,
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
142 unsigned int timeoutInSeconds)
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
143 {
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
144 std::string headersInJsonString;
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
145 ToJsonString(headersInJsonString, headers);
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
146 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
147 payload, timeoutInSeconds);
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
148 }
aad37d0b6407 Added LayerWidget::RemoveLayer + DELETE commands in WebService
am@osimis.io
parents: 309
diff changeset
149
434
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
150 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
151 const HttpHeaders &headers,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
152 Orthanc::IDynamicObject *payload,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
153 MessageHandler<IWebService::HttpRequestSuccessMessage> *successCallable,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
154 MessageHandler<IWebService::HttpRequestErrorMessage> *failureCallable,
3a8bcc45c221 moved the HTTP cache from OrthancApiClient to BaseWebService (not implemented yet in WASM)
am@osimis.io
parents: 418
diff changeset
155 unsigned int timeoutInSeconds)
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
156 {
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
157 std::string headersInJsonString;
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
158 ToJsonString(headersInJsonString, headers);
418
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
159 WasmWebService_GetAsync(successCallable, failureCallable, relativeUri.c_str(),
c23df8b3433b refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 417
diff changeset
160 headersInJsonString.c_str(), payload, timeoutInSeconds);
299
3897f9f28cfa backup work in progress: updated messaging framework with ICallable
am@osimis.io
parents: 257
diff changeset
161 }
435
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
162
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
163 void WasmWebService::NotifyHttpSuccessLater(boost::shared_ptr<BaseWebService::CachedHttpRequestSuccessMessage> cachedMessage,
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
164 Orthanc::IDynamicObject* payload, // takes ownership
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
165 MessageHandler<IWebService::HttpRequestSuccessMessage>* successCallback)
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 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
168 notification->cachedMessage = cachedMessage;
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
169 notification->payload.reset(payload);
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
170 notification->successCallback = successCallback;
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
171
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
172 WasmWebService_ScheduleLaterCachedSuccessNotification(notification);
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
173 }
e641d3978856 WasmWebService now using BaseWebService and supporting cache
am@osimis.io
parents: 434
diff changeset
174
221
d7b2590744f8 wip: building applications reusable in SDL and WASM
am@osimis.io
parents:
diff changeset
175 }