changeset 264:6b98ac45aaee am-2

documented how to compile and execute WASM samples
author am@osimis.io
date Tue, 21 Aug 2018 16:36:01 +0200
parents 77fdab5b5d6e
children 30dc6e383b0b
files Applications/Samples/Web/index.html Applications/Samples/Web/simple-viewer.ts Platforms/Wasm/nginx.local.conf README
diffstat 4 files changed, 64 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/Web/index.html	Tue Jul 17 18:28:12 2018 +0200
+++ b/Applications/Samples/Web/index.html	Tue Aug 21 16:36:01 2018 +0200
@@ -14,7 +14,7 @@
 
 <body>
     <ul>
-        <li><a href="simple-viewer.html">Simple Viewer</a></li>
+        <li><a href="simple-viewer.html?instance1=XXXX&instance2=YYYY">Simple Viewer</a></li>
     </ul>
 </body>
 
--- a/Applications/Samples/Web/simple-viewer.ts	Tue Jul 17 18:28:12 2018 +0200
+++ b/Applications/Samples/Web/simple-viewer.ts	Tue Aug 21 16:36:01 2018 +0200
@@ -1,3 +1,3 @@
 ///<reference path='../../../Platforms/Wasm/wasm-application.ts'/>
 
-InitializeWasmApplication("OrthancStoneSimpleViewer", "../../../stone-orthanc");
+InitializeWasmApplication("OrthancStoneSimpleViewer", "/orthanc");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Platforms/Wasm/nginx.local.conf	Tue Aug 21 16:36:01 2018 +0200
@@ -0,0 +1,44 @@
+# Local config to serve the WASM samples static files and reverse proxy Orthanc.
+# Uses port 9977 instead of 80.
+
+# `events` section is mandatory
+events {
+  worker_connections 1024; # Default: 1024
+}
+
+http {
+
+  # prevent nginx sync issues on OSX
+  proxy_buffering off;
+
+  server {
+    listen 9977 default_server;
+    client_max_body_size 4G;
+
+    # location may have to be adjusted depending on your OS and nginx install
+    include /etc/nginx/mime.types;
+    # if not in your system mime.types, add this line to support WASM:
+    # types {
+    #    application/wasm                      wasm; 
+    # }
+
+    # serve WASM static files
+    root build-web/;
+    location / {
+	}
+
+    # reverse proxy orthanc
+	location /orthanc/ {
+		rewrite /orthanc(.*) $1 break;
+		proxy_pass http://127.0.0.1:8042;
+		proxy_set_header Host $http_host;
+		proxy_set_header my-auth-header good-token;
+		proxy_request_buffering off;
+		proxy_max_temp_file_size 0;
+		client_max_body_size 0;
+	}
+
+
+  }
+  
+}
--- a/README	Tue Jul 17 18:28:12 2018 +0200
+++ b/README	Tue Aug 21 16:36:01 2018 +0200
@@ -87,7 +87,24 @@
 http://book.orthanc-server.com/developers/stone.html
 
 Stone of Orthanc comes with several sample applications in the
-"Samples" folder. These samples use SDL.
+"Samples" folder. These samples can be compiled into Web Assembly
+or into native SDL applications.
+
+to build the WASM samples:
+```
+cd ~/orthanc-stone/Platforms/Wasm
+./build-wasm.sh
+```
+
+to serve the WASM samples:
+```
+# launch an Orthanc listening on 8042 port:
+Orthanc
+
+# launch an nginx that will serve the WASM static files and reverse proxy Orthanc
+sudo nginx -p $(pwd) -c nginx.local.conf
+```
+Now, you can open the samples in http://localhost:9977
 
 
 Licensing