Rinnegatamante / lpp-3ds

Lua Player Plus for 3DS
GNU General Public License v3.0
180 stars 32 forks source link

Non blocking (or periodic callback calling) Network functions #41

Closed Wolvan closed 8 years ago

Wolvan commented 8 years ago

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)
Rinnegatamante commented 8 years ago

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

Wolvan commented 8 years ago

Alright, got it