Rinnegatamante/lpp-3ds

Non blocking (or periodic callback calling) Network functions

Closed this issue · 2 comments

Right now, all Network functions are blocking. Calling downloadFile makes the application looks like it stopped responding and there is no way to indicate that the System is still doing something to the user.
I suggest adding a callback function to Network.downloadFile and maybe Network.requestString too (although requestString usually doesn't block as long as big file downloads) that gets called so developers can use that to show a progress bar for example, or simply allow for some kind of animated indicator that the download is still going.

If possible, adding the currently downloaded size and the full size of the file in question as arguments of the callback.
Example:

Network.downloadFile("http://www.example.com/example.file", "/example.file",...., function(currentBytes, maxBytes)
   Screen.clearScreen(TOP_SCREEN)
   Screen.debugPrint(5,5,"Currently downloaded "..currentByte.."/"..maxBytes.." Bytes", Color.new(255,255,255), TOP_SCREEN)
end)

You can write an asynchronous downloader using socketing.
Adding such a thing it's not that essential atm.

Alright, got it