When using UrlLoaders to load some JSON, I'm encountering some issues in my app.
First of all, although the UrlLoader has separate onComplete event, running this seems to block the rest of the app. This is very noticeable in my app, because the JSON decoding that I do in the Event.COMPLETE event might take some time. I tried some stuff with coroutines and yielding there, but this is not even possible in the Event.COMPLETE handler (c-boundary stuff).
So my question is: is it in some way possible to make the UrlLoader 'asynchronous' (complete event not blocking the rest of the execution)?
Related to this is the error handling of json.decode. I know I have posted a message about this before, but since it is related I have decided to ask it again: when encountering illegal/erroneous JSON, is it possible to recover from this? Currently, crashing the app or the gideros player (with a runtime error) is the only thing that happens.
Thank you for your time,
-Vincent
Comments
yes sorry I forgot to respond, well I checked the original json lib (cpp implementation) and it also breaks the app.
Although there is a submodule json.safe, which should decode strings more safely, but even it crashes the app on completely incorrect strings.
Safe mode can be used like this:
And in this case I don't know if anything could help you much, but what you could try, is using Lua Socket with very small settimeout value:
http://stackoverflow.com/questions/5795419/lua-socket-asynchronous-calls