changeset 240:ddbb339ed4cf am

orthancBaseUrl is now configurable
author am@osimis.io
date Wed, 20 Jun 2018 09:43:36 +0200
parents 72b711f22a2b
children a4197519eb55
files Applications/Samples/Web/simple-viewer.ts Platforms/Wasm/WasmWebService.cpp Platforms/Wasm/WasmWebService.h Platforms/Wasm/wasm-application.ts
diffstat 4 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/Web/simple-viewer.ts	Wed Jun 20 09:26:15 2018 +0200
+++ b/Applications/Samples/Web/simple-viewer.ts	Wed Jun 20 09:43:36 2018 +0200
@@ -1,3 +1,3 @@
 ///<reference path='../../../Platforms/Wasm/wasm-application.ts'/>
 
-InitializeWasmApplication("OrthancStoneSimpleViewer");
+InitializeWasmApplication("OrthancStoneSimpleViewer", "../../../stone-orthanc");
--- a/Platforms/Wasm/WasmWebService.cpp	Wed Jun 20 09:26:15 2018 +0200
+++ b/Platforms/Wasm/WasmWebService.cpp	Wed Jun 20 09:43:36 2018 +0200
@@ -48,6 +48,11 @@
    }
   }
 
+  void EMSCRIPTEN_KEEPALIVE WasmWebService_SetBaseUrl(const char* baseUrl)
+  {
+    OrthancStone::WasmWebService::GetInstance().SetBaseUrl(baseUrl);
+  }
+
 #ifdef __cplusplus
 }
 #endif
--- a/Platforms/Wasm/WasmWebService.h	Wed Jun 20 09:26:15 2018 +0200
+++ b/Platforms/Wasm/WasmWebService.h	Wed Jun 20 09:43:36 2018 +0200
@@ -11,7 +11,7 @@
 
     // Private constructor => Singleton design pattern
     WasmWebService() :
-      base_("../../")   // TODO: this should be configurable from the JS code !
+      base_("../../")   // note: this is configurable from the JS code by calling WasmWebService_SetBaseUrl
     {
     }
 
--- a/Platforms/Wasm/wasm-application.ts	Wed Jun 20 09:26:15 2018 +0200
+++ b/Platforms/Wasm/wasm-application.ts	Wed Jun 20 09:43:36 2018 +0200
@@ -86,7 +86,7 @@
   UpdateContentThread();
 }
 
-function InitializeWasmApplication(wasmModuleName: string) {
+function InitializeWasmApplication(wasmModuleName: string, orthancBaseUrl: string) {
   
   Stone.Framework.Configure(wasmModuleName);
 
@@ -106,6 +106,8 @@
     WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
     NotifyUpdateContent = StoneFrameworkModule.cwrap('NotifyUpdateContent', null, []);
 
+    StoneFrameworkModule.ccall('WasmWebService_SetBaseUrl', null, ['string'], [orthancBaseUrl]);
+
     // Prevent scrolling
     document.body.addEventListener('touchmove', function (event) {
       event.preventDefault();