comparison Platforms/Wasm/wasm-application-runner.ts @ 418:c23df8b3433b

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Nov 2018 18:32:48 +0100
parents e33659decec5
children 26b90b110719
comparison
equal deleted inserted replaced
417:aee3d7941c9b 418:c23df8b3433b
8 declare var StoneFrameworkModule : Stone.Framework; 8 declare var StoneFrameworkModule : Stone.Framework;
9 9
10 // global functions 10 // global functions
11 var WasmWebService_NotifyError: Function = null; 11 var WasmWebService_NotifyError: Function = null;
12 var WasmWebService_NotifySuccess: Function = null; 12 var WasmWebService_NotifySuccess: Function = null;
13 var WasmWebService_SetBaseUri: Function = null;
14 var WasmDoAnimation: Function = null; 13 var WasmDoAnimation: Function = null;
15 var SetStartupParameter: Function = null; 14 var SetStartupParameter: Function = null;
16 var CreateWasmApplication: Function = null; 15 var CreateWasmApplication: Function = null;
17 var CreateCppViewport: Function = null; 16 var CreateCppViewport: Function = null;
18 var ReleaseCppViewport: Function = null; 17 var ReleaseCppViewport: Function = null;
56 // } 55 // }
57 56
58 function _InitializeWasmApplication(orthancBaseUrl: string): void { 57 function _InitializeWasmApplication(orthancBaseUrl: string): void {
59 58
60 CreateWasmApplication(); 59 CreateWasmApplication();
61 WasmWebService_SetBaseUri(orthancBaseUrl);
62
63 60
64 // parse uri and transmit the parameters to the app before initializing it 61 // parse uri and transmit the parameters to the app before initializing it
65 let parameters = GetUriParameters(); 62 let parameters = GetUriParameters();
66 63
67 for (let key in parameters) { 64 for (let key in parameters) {
68 if (parameters.hasOwnProperty(key)) { 65 if (parameters.hasOwnProperty(key)) {
69 SetStartupParameter(key, parameters[key]); 66 SetStartupParameter(key, parameters[key]);
70 } 67 }
71 } 68 }
72 69
73 StartWasmApplication(); 70 StartWasmApplication(orthancBaseUrl);
74 71
75 // trigger a first resize of the canvas that have just been initialized 72 // trigger a first resize of the canvas that has just been initialized
76 Stone.WasmViewport.ResizeAll(); 73 Stone.WasmViewport.ResizeAll();
77 74
78 DoAnimationThread(); 75 DoAnimationThread();
79 } 76 }
80 77
90 87
91 SetStartupParameter = StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']); 88 SetStartupParameter = StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']);
92 CreateWasmApplication = StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']); 89 CreateWasmApplication = StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']);
93 CreateCppViewport = StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []); 90 CreateCppViewport = StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []);
94 ReleaseCppViewport = StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']); 91 ReleaseCppViewport = StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']);
95 StartWasmApplication = StoneFrameworkModule.cwrap('StartWasmApplication', null, ['number']); 92 StartWasmApplication = StoneFrameworkModule.cwrap('StartWasmApplication', null, ['string']);
96 93
97 WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']); 94 WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']);
98 WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']); 95 WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
99 WasmWebService_SetBaseUri = StoneFrameworkModule.cwrap('WasmWebService_SetBaseUri', null, ['string']);
100 WasmDoAnimation = StoneFrameworkModule.cwrap('WasmDoAnimation', null, []); 96 WasmDoAnimation = StoneFrameworkModule.cwrap('WasmDoAnimation', null, []);
101 97
102 SendMessageToStoneApplication = StoneFrameworkModule.cwrap('SendMessageToStoneApplication', 'string', ['string']); 98 SendMessageToStoneApplication = StoneFrameworkModule.cwrap('SendMessageToStoneApplication', 'string', ['string']);
103 99
104 console.log("Connecting C++ methods to JS methods - done"); 100 console.log("Connecting C++ methods to JS methods - done");