comparison Platforms/Wasm/WasmWebService.js @ 509:1b9973905e15 bgo-commands-codegen

Fix to use js callbacks attached to 'window' + dummy changes in cmake files
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 06 Mar 2019 10:57:02 +0100
parents 5055031f4a06
children 861c080ef47b
comparison
equal deleted inserted replaced
508:7105a0bad250 509:1b9973905e15
35 xhr.send(); 35 xhr.send();
36 }, 36 },
37 37
38 WasmWebService_ScheduleLaterCachedSuccessNotification: function (brol) { 38 WasmWebService_ScheduleLaterCachedSuccessNotification: function (brol) {
39 setTimeout(function() { 39 setTimeout(function() {
40 WasmWebService_NotifyCachedSuccess(brol); 40 window.WasmWebService_NotifyCachedSuccess(brol);
41 }, 0); 41 }, 0);
42 }, 42 },
43 43
44 WasmWebService_PostAsync: function(callableSuccess, callableFailure, url, headersInJsonString, body, bodySize, payload, timeoutInSeconds) { 44 WasmWebService_PostAsync: function(callableSuccess, callableFailure, url, headersInJsonString, body, bodySize, payload, timeoutInSeconds) {
45 var xhr = new XMLHttpRequest(); 45 var xhr = new XMLHttpRequest();
60 if (xhr.status === 200) { 60 if (xhr.status === 200) {
61 var s = xhr.getAllResponseHeaders(); 61 var s = xhr.getAllResponseHeaders();
62 var headers = _malloc(s.length + 1); 62 var headers = _malloc(s.length + 1);
63 stringToUTF8(s, headers, s.length + 1); 63 stringToUTF8(s, headers, s.length + 1);
64 64
65 WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response), 65 window.WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response),
66 this.response.byteLength, headers, payload); 66 this.response.byteLength, headers, payload);
67 } else { 67 } else {
68 WasmWebService_NotifyError(callableFailure, url_, payload); 68 window.WasmWebService_NotifyError(callableFailure, url_, payload);
69 } 69 }
70 } 70 }
71 } 71 }
72 72
73 xhr.send(new Uint8ClampedArray(HEAPU8.buffer, body, bodySize)); 73 xhr.send(new Uint8ClampedArray(HEAPU8.buffer, body, bodySize));
92 if (xhr.status === 200) { 92 if (xhr.status === 200) {
93 var s = xhr.getAllResponseHeaders(); 93 var s = xhr.getAllResponseHeaders();
94 var headers = _malloc(s.length + 1); 94 var headers = _malloc(s.length + 1);
95 stringToUTF8(s, headers, s.length + 1); 95 stringToUTF8(s, headers, s.length + 1);
96 96
97 WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response), 97 window.WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response),
98 this.response.byteLength, headers, payload); 98 this.response.byteLength, headers, payload);
99 } else { 99 } else {
100 WasmWebService_NotifyError(callableFailure, url_, payload); 100 window.WasmWebService_NotifyError(callableFailure, url_, payload);
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 xhr.send(); 105 xhr.send();