We know,It is luasocket in lua binding.
but, how do in js binding?
the network game must be think.
You have to bind sockets library of Android or iOS to Javascript.
I’m looking around because I require this also. You might wanna checkout http://socket.io
oh,It is a difficult work for me.
I am not c++ programer, I just know a little script code.
and so,socket.io dont support windows?
socket.io will work on the browser (cocos2d-html5), but not on the js-bindings… as it requires the browser’s networking layer. I think at some point we can emulate that… Some time ago I wrote a very simple layer for emulating XMLHttpRequest, maybe someone can do the same with a more complete version. If cocos2d-x had a networking layer, we could easily wrap it automatically (the same way we’re wrapping the rest of cocos2d-x) for it to be used in javascript.
Rolando
walzer
September 12, 2012, 2:26pm
#5
I think the better way is to add a wrapper on both XMLHttpRequest and libcurl to fit the requirement.
jamesm
March 11, 2013, 4:32pm
#6
We’ve written a small wrapper object around cocos2d::extension::CCHttpRequest and then generated JS bindings from this. It’s then a simple API to work with at the JS level. However, a cross-platform (including HTML5) would be better in the long run.
There is a working XMLHttpRequest for local requests here:
//
// XMLHTTPRequest.cpp
// FakeWebGL
//
// Created by Rolando Abarca on 10/5/12.
// Copyright (c) 2012 Rolando Abarca. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
This file has been truncated. show original
//
// XMLHTTPRequest.h
// FakeWebGL
//
// Created by Rolando Abarca on 10/5/12.
// Copyright (c) 2012 Rolando Abarca. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
This file has been truncated. show original
Remote requests (http & https, including async requests) are going to be added soon. Those two files are depending on a set of macros defined here:
//
// glue.h
// webglshim
//
// Created by Rolando Abarca on 10/5/12.
// Copyright (c) 2012 Rolando Abarca. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
This file has been truncated. show original
I think at some point I’ll add those two to the current jsbindings in cocos2d-x