How to make a http/websocket request in cocos2d-html5?

Hi, i am new to Cocos2d-html5.

I wonder how to make a http/websocket request in cocos2d-html5 ?

There is a HttpClient in cocos2dx, which I can’t find in cocos2d-html5.

Could anyone help me ?

Please refer to test cases of /samples/tests/extension tests/websocket tests.

If you can’t find it, please update your code to latest version of github develop branch, and then update submodule to latest version manually.

Shun Lin wrote:

Please refer to test cases of /samples/tests/extension tests/websocket tests.
>
If you can’t find it, please update your code to latest version of github develop branch, and then update submodule to latest version manually.

Tks I found the sample.

Does it work built by JSBinding for android ?

Yes, it is working on android and iOS.

for me personally finding websocket is too advance for simple http get or post request.
there are much more work involve to simulate simple get request (for example just getting simple data from php server)
it will be really nice to add httpClient class to cocos HTML5 and use XMLHttpRequest

at the moment on HTML5 i use own XMLHttpRequest class and in iphone use HttpClient
but i will have no idea how to JSBinding my HTML5 code using XMLHttpRequest, don’t think it will work under IOS or android.

Zax Ma wrote:

for me personally finding websocket is too advance for simple http get or post request.
there are much more work involve to simulate simple get request (for example just getting simple data from php server)
it will be really nice to add httpClient class to cocos HTML5 and use XMLHttpRequest
>
at the moment on HTML5 i use own XMLHttpRequest class and in iphone use HttpClient
but i will have no idea how to JSBinding my HTML5 code using XMLHttpRequest, don’t think it will work under IOS or android.

Tks for the advice!

I just try registering a cpp XMLHttpRequest function through JSBinding, but it seems not to work. I’m confused too.

XMLHttpRequest is supported 3 months ago. Please refer to https://github.com/cocos2d/cocos2d-x/pull/2561 .