AssetsManager do the networking on main thread

That’s what AssetsManagerTest looks like.

So developers, not cocos2d-x have to do the threading, what we want is:

  1. cocos2d-x do the threading, games just get callback, like CCHttpClient
  2. user can cancel downloading anytime

will you guys consider doing these?

is it this forbidden by apple to do the networking on the main thread ?

sKy wAr wrote:

That’s what AssetsManagerTest looks like.
>
So developers, not cocos2d-x have to do the threading, what we want is:

  1. cocos2d-x do the threading, games just get callback, like CCHttpClient
  2. user can cancel downloading anytime
    >
    will you guys consider doing these?

1:you can use CCDirector::sharedDirector()->getScheduler()->scheduleSelector to do callback to notify the main thread .2:you can use close of curl to cancel downloading
BTW, the AssetsManagerTest is not so stable , if you click enter button 2 times, it will crash, maybe they don’t have enough time to test it , but it’s just a guiding for me.:slight_smile:

Yep, AssetsManager will support downloading in a new thread later.
There are two ways to do it
* Change update(), make it download resources in a new thread.
* Add a new method, such as updateAsync(), to download resources in a new thread.

Which is better?

Of course, AssetsManager should add a method to stop downloading.

Thank you for your feedback.

I have created #1857, #1858 and #1859 for them.

Minggo Zhang wrote:

I have created #1857, #1858 and #1859 for them.

should we add an error callback of downloading?
OK, I hope it more useful :
1.support pause, resume , cancel downloading.
2.continue from last downloading.

Minggo Zhang wrote:

Yep, AssetsManager will support downloading in a new thread later.
There are two ways to do it
* Change update(), make it download resources in a new thread.
* Add a new method, such as updateAsync(), to download resources in a new thread.
>
Which is better?
>
Of course, AssetsManager should add a method to stop downloading.
>
Thank you for your feedback.

option2,adding updateAsync() method, so that AssetsManager can do both sync and async downloading? it may not be a good thing to have too many options.
plus, it needs a lot more effort to document it, as i can see you guys are very good coders, not very good at documenting, :slight_smile:

i prefer option1, “* Change update(), make it download resources in a new thread.” and dispatch message to my main thread(getting call back) for:

  1. progress, so that i can modify my progress bar
  2. errors, sometimes games are Forbidden to download new versions to continue.

and i think pausing, resuming are alot to ask

C ZhangsKy wAr

Thank you for your suggestion.

About errors, i think i can invoke a delegate when there is an error, but i think it is impossible to return error type,
because there are so many types of errors.
What’s your opinion?

Minggo Zhang wrote:

C ZhangsKy wAr
>
Thank you for your suggestion.
>
About errors, i think i can invoke a delegate when there is an error, but i think it is impossible to return error type,
because there are so many types of errors.
What’s your opinion?

Exactly , I just care two errors : net and I/O errors , so I think it will be more useful if we can return the two error types at current version.
in the future , we can add more error types if someone wants to improve it.

Ok, i will update this thread when i pull a request.

I suggest to use non-blocking mode in the main thread,not use thread

I have sent a pull request to download resources in a new thread.

@Dpull com
Could you describe it more detail?

Using the curl_multi_init to create a non-blocking’s http request, through the the update function gradually the download is complete, to return to the: Success, failure, in the downloading