comparison Platforms/Wasm/WasmWebService.cpp @ 247:3d523c9a8f0d am

trying to use boost::signals2 even more.
author am@osimis.io
date Mon, 02 Jul 2018 12:32:02 +0200
parents ddbb339ed4cf
children
comparison
equal deleted inserted replaced
246:5470b15f7cf2 247:3d523c9a8f0d
14 const char* uri, 14 const char* uri,
15 const void* body, 15 const void* body,
16 size_t bodySize, 16 size_t bodySize,
17 void* payload); 17 void* payload);
18 18
19 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyError(void* callback, 19 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyError(void* observer,
20 const char* uri, 20 const char* uri,
21 void* payload) 21 void* payload)
22 { 22 {
23 if (callback == NULL) 23 if (observer == NULL)
24 { 24 {
25 throw; 25 throw;
26 } 26 }
27 else 27 else
28 { 28 {
29 reinterpret_cast<OrthancStone::IWebService::ICallback*>(callback)-> 29 reinterpret_cast<OrthancStone::IWebService::IWebServiceObserver*>(observer)->
30 NotifyError(uri, reinterpret_cast<Orthanc::IDynamicObject*>(payload)); 30 OnRequestError(uri, reinterpret_cast<Orthanc::IDynamicObject*>(payload));
31 } 31 }
32 } 32 }
33 33
34 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifySuccess(void* callback, 34 void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifySuccess(void* observer,
35 const char* uri, 35 const char* uri,
36 const void* body, 36 const void* body,
37 size_t bodySize, 37 size_t bodySize,
38 void* payload) 38 void* payload)
39 { 39 {
40 if (callback == NULL) 40 if (observer == NULL)
41 { 41 {
42 throw; 42 throw;
43 } 43 }
44 else 44 else
45 { 45 {
46 reinterpret_cast<OrthancStone::IWebService::ICallback*>(callback)-> 46 reinterpret_cast<OrthancStone::IWebService::IWebServiceObserver*>(observer)->
47 NotifySuccess(uri, body, bodySize, reinterpret_cast<Orthanc::IDynamicObject*>(payload)); 47 OnRequestSuccess(uri, body, bodySize, reinterpret_cast<Orthanc::IDynamicObject*>(payload));
48 } 48 }
49 } 49 }
50 50
51 void EMSCRIPTEN_KEEPALIVE WasmWebService_SetBaseUrl(const char* baseUrl) 51 void EMSCRIPTEN_KEEPALIVE WasmWebService_SetBaseUrl(const char* baseUrl)
52 { 52 {
73 { 73 {
74 base_ = base; 74 base_ = base;
75 } 75 }
76 } 76 }
77 77
78 void WasmWebService::ScheduleGetRequest(ICallback& callback, 78 void WasmWebService::ScheduleGetRequest(IWebServiceObserver* observer,
79 boost::shared_ptr<boost::noncopyable> tracker,
79 const std::string& uri, 80 const std::string& uri,
80 Orthanc::IDynamicObject* payload) 81 Orthanc::IDynamicObject* payload)
81 { 82 {
82 std::string url = base_ + uri; 83 std::string url = base_ + uri;
83 WasmWebService_ScheduleGetRequest(&callback, url.c_str(), payload); 84 WasmWebService_ScheduleGetRequest(observer, url.c_str(), payload);
84 } 85 }
85 86
86 void WasmWebService::SchedulePostRequest(ICallback& callback, 87 void WasmWebService::SchedulePostRequest(IWebServiceObserver* observer,
88 boost::shared_ptr<boost::noncopyable> tracker,
87 const std::string& uri, 89 const std::string& uri,
88 const std::string& body, 90 const std::string& body,
89 Orthanc::IDynamicObject* payload) 91 Orthanc::IDynamicObject* payload)
90 { 92 {
91 std::string url = base_ + uri; 93 std::string url = base_ + uri;
92 WasmWebService_SchedulePostRequest(&callback, url.c_str(), 94 WasmWebService_SchedulePostRequest(observer, url.c_str(),
93 body.c_str(), body.size(), payload); 95 body.c_str(), body.size(), payload);
94 } 96 }
95 } 97 }