Mercurial > hg > orthanc-stone
view Platforms/WebAssembly/WasmWebService.js @ 232:7d3b2c4f9ba1 am
don't cache hasUpdate_ since its not updated when we update the underlying hierarchy (i.e: when the child of a layout is a layout without child when it is added but childs are added later ...)
author | am@osimis.io |
---|---|
date | Fri, 15 Jun 2018 11:23:04 +0200 |
parents | b0ba3b38a23c |
children |
line wrap: on
line source
mergeInto(LibraryManager.library, { WasmWebService_ScheduleGetRequest: function(callback, url, payload) { // Directly use XMLHttpRequest (no jQuery) to retrieve the raw binary data // http://www.henryalgus.com/reading-binary-files-using-jquery-ajax/ var xhr = new XMLHttpRequest(); var tmp = UTF8ToString(url); xhr.open('GET', tmp, true); xhr.responseType = 'arraybuffer'; xhr.onreadystatechange = function() { if (this.readyState == XMLHttpRequest.DONE) { if (xhr.status === 200) { // TODO - Is "new Uint8Array()" necessary? This copies the // answer to the WebAssembly stack, hence necessitating // increasing the TOTAL_STACK parameter of Emscripten WasmWebService_NotifySuccess(callback, tmp, new Uint8Array(this.response), this.response.byteLength, payload); } else { WasmWebService_NotifyError(callback, tmp, payload); } } } xhr.send(); }, WasmWebService_SchedulePostRequest: function(callback, url, body, bodySize, payload) { var xhr = new XMLHttpRequest(); var tmp = UTF8ToString(url); xhr.open('POST', tmp, true); xhr.responseType = 'arraybuffer'; xhr.setRequestHeader('Content-type', 'application/octet-stream'); xhr.onreadystatechange = function() { if (this.readyState == XMLHttpRequest.DONE) { if (xhr.status === 200) { WasmWebService_NotifySuccess(callback, tmp, new Uint8Array(this.response), this.response.byteLength, payload); } else { WasmWebService_NotifyError(callback, tmp, payload); } } } xhr.send(new Uint8ClampedArray(HEAPU8.buffer, body, bodySize)); } });