I try use live updates in my game. I do this steps:
- Set live updates to zip-mode
- Publish html5 application with live update content
- unpack
defold.resourcepack_js-web_XXX.zip
inupdates
folder nearindex.html
- pack index.html+bundles in index.zip and upload to itch.io or games.yandex.ru
I have following errors on some browser and devices. Sometimes all ok
I heve this code for upload missing bundles:
public function loadCollectionProxy(name: String, collectionProxy: Url, enableOnFinish: Bool) {
var missing = Collectionproxy.missing_resources(collectionProxy);
var pending = 0;
function checkPendings() {
if (pending == 0) {
trace('Start load collection ${name}');
Msg.post(collectionProxy, CollectionproxyMessages.load);
} else {
trace('Collection proxy ${name} pending for ${pending}');
}
}
var manifest = Resource.get_current_manifest();
PairTools.pairsEach(missing, function(_, hash) {
pending++;
var url = './updates/${hash}';
trace('Request ${url}');
Http.request(url, "GET", function(_, _, resp) {
trace('Responce ${url} ${resp.status}');
if (resp.status == 200 || resp.status == 304) {
Resource.store_resource(manifest, resp.response, hash, function(_, _, status) {
trace('Resource stored ${hash} ${status}');
if (status) {
pending--;
checkPendings();
} else {
ErrorPopup.display('Error store resource ${url}');
}
});
} else {
ErrorPopup.display('Error load resource ${url}');
}
});
});
var status = { done: false };
_tasks.push(CoTask.LoadCollectionProxy(name, collectionProxy, enableOnFinish, status));
checkPendings();
while (!status.done) {
Coroutine.yield();
}
}