Lua binding for Cocos2dx Downloader

I have manually binding a singleton downloader for lua
Downloader is not exported for lua in the official release branch
The C++ path of Downloader is (cocos/network/Downloader)
It’s useful for multithreads downloads !

Github -

Example :
local downloader = Require("[Your Path].Downloader")
local taskId = downloader.downloadData(
https://httpbin.org/get”,
function (result, data)
print("download ended – ", result, data)
end
)

downloader.setProgressCallBack(taskId,
function (bytesRec, totalBytesRec, totalBytesExpected)
print("download progress – ", totalBytesRec*100/totalBytesExpected)
end)

Any suggestions is welcomed !

Should probably add a github issue to the cocos2d-x project. I don’t see why every single c++ class and method wouldn’t be given generated bindings considering there are already bindings for most everything.

Yes, i find HttpRequest/HttpClient is not exported too, i think it’s probably because these classes need manually binding, since the lua callback function is necessary for these classes once exported !

I will optimize these code after, and see if it can be committed to the project !

1 Like