changeset 255:65562a28fe05 am-2

fixes for WASM
author am@osimis.io
date Tue, 03 Jul 2018 13:19:56 +0200
parents abc1c6231947
children 9afafb192180
files Platforms/Wasm/CMakeLists.txt Platforms/Wasm/Defaults.cpp Platforms/Wasm/WasmWebService.h Platforms/Wasm/wasm-application.ts Resources/CMake/OrthancStoneConfiguration.cmake
diffstat 5 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Platforms/Wasm/CMakeLists.txt	Tue Jul 03 11:49:02 2018 +0200
+++ b/Platforms/Wasm/CMakeLists.txt	Tue Jul 03 13:19:56 2018 +0200
@@ -61,6 +61,7 @@
 
 macro(BuildSample Target Header Sample)
   add_executable(${Target}
+    ${STONE_WASM_SOURCES}
 
     ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleMainWasm.cpp
 #    ${ORTHANC_STONE_ROOT}/Applications/Samples/SampleApplicationContext.cpp
--- a/Platforms/Wasm/Defaults.cpp	Tue Jul 03 11:49:02 2018 +0200
+++ b/Platforms/Wasm/Defaults.cpp	Tue Jul 03 13:19:56 2018 +0200
@@ -67,6 +67,7 @@
     printf("CreateWasmApplication\n");
 
     application.reset(CreateUserApplication(broker));
+    WasmWebService::SetBroker(broker);
 
     startupParametersBuilder.Clear();
   }
@@ -86,7 +87,6 @@
     application->DeclareStartupOptions(options);
     startupParametersBuilder.GetStartupParameters(parameters, options);
 
-    WasmWebService::SetBroker(broker);
     context.reset(new OrthancStone::BasicApplicationContext(OrthancStone::WasmWebService::GetInstance()));
     application->Initialize(context.get(), statusBar_, parameters);
     application->InitializeWasm();
--- a/Platforms/Wasm/WasmWebService.h	Tue Jul 03 11:49:02 2018 +0200
+++ b/Platforms/Wasm/WasmWebService.h	Tue Jul 03 13:19:56 2018 +0200
@@ -23,6 +23,7 @@
     {
       if (broker_ == NULL)
       {
+        printf("WasmWebService::GetInstance(): broker not initialized\n");
         throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
       }
       static WasmWebService instance(*broker_);
--- a/Platforms/Wasm/wasm-application.ts	Tue Jul 03 11:49:02 2018 +0200
+++ b/Platforms/Wasm/wasm-application.ts	Tue Jul 03 13:19:56 2018 +0200
@@ -10,6 +10,7 @@
 // global functions
 var WasmWebService_NotifyError: Function = null;
 var WasmWebService_NotifySuccess: Function = null;
+var WasmWebService_SetBaseUri: Function = null;
 var NotifyUpdateContent: Function = null;
 var SetStartupParameter: Function = null;
 var CreateWasmApplication: Function = null;
@@ -66,10 +67,12 @@
 }
 
 
-function _InitializeWasmApplication(canvasId: string): void {
+function _InitializeWasmApplication(canvasId: string, orthancBaseUrl: string): void {
 
   /************************************** */
   CreateWasmApplication();
+  WasmWebService_SetBaseUri(orthancBaseUrl);
+
 
   // parse uri and transmit the parameters to the app before initializing it
   var parameters = GetUriParameters();
@@ -104,15 +107,16 @@
 
     WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']);
     WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
+    WasmWebService_SetBaseUri = StoneFrameworkModule.cwrap('WasmWebService_SetBaseUri', null, ['string']);
     NotifyUpdateContent = StoneFrameworkModule.cwrap('NotifyUpdateContent', null, []);
 
-    StoneFrameworkModule.ccall('WasmWebService_SetBaseUri', null, ['string'], [orthancBaseUrl]);
+    console.log("Connecting C++ methods to JS methods - done - 2");
 
     // Prevent scrolling
     document.body.addEventListener('touchmove', function (event) {
       event.preventDefault();
     }, false);
 
-    _InitializeWasmApplication("canvas");
+    _InitializeWasmApplication("canvas", orthancBaseUrl);
   });
 }
\ No newline at end of file
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Tue Jul 03 11:49:02 2018 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Tue Jul 03 13:19:56 2018 +0200
@@ -160,10 +160,13 @@
 else()
   list(APPEND APPLICATIONS_SOURCES
     ${ORTHANC_STONE_ROOT}/Applications/Wasm/StartupParametersBuilder.cpp
+    )
+
+  set(STONE_WASM_SOURCES
     ${ORTHANC_STONE_ROOT}/Platforms/Wasm/Defaults.cpp
     ${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmWebService.cpp
     ${ORTHANC_STONE_ROOT}/Platforms/Wasm/WasmViewport.cpp
-    )
+  )
 endif()
 
 list(APPEND ORTHANC_STONE_SOURCES