We will fix the issue ASAP. But you are appreciated if you guys can help to test and review the codes. About how to test IPv6 compatibility can refer to the apple doc.
It is better to add a comment to the issue above if you find any problem.
@zhangleipku1 thanks for testing. I am not sure if connecting with ipv6.google.com can be used for testing IPv6-only compatibility or not. But the the apple doc provide a way to test. And i just tested as the doc said, HttpClient works as expected.
v2 is fixed except of windows and wp8, has compiling error on these two platforms because of upgrading libwebsockets. Will support them ASAP.
How to do
You can just update libwebsockets and CURL like this:
modify Cocos2d-x root/external/config.json to update the dependency version. For v3.x the dependency version is v3-deps-94, and for v2.x it is v2-deps-6
execute the download-deps.py script in your Cocos2d-x root.
Edit: i also modify Console and ScriptingCore to support IPv6-only network in this PR, but i think it is not needed for you to do like this because they are just for testing, not be used in game logic.
If you are using v2.x, you also need to apply this commit to fix compiling error.
Edit: windows compiling issue of v2 is fixed, you need to download v2-deps-v7 instead if you work on windows. And you may need to link ws2_32.lib in libexternal project. Refer to this commit for detail information.
Cocos2d-x root/external/config.json and download-deps.py scripts don’t exist in v2.2.2.
Please tell me what to do, to update libwebsockets and CURL in cocos2dx v2.2.2.
Yep, updatelibwebsockets and CURL can resolve it. Console and ScriptingCore related codes are just for debug purpose, so you don’t have to care about it.
So i just need to replace the libwebsockets and CURL folder in external folder?
But i can’t rebuild the library, got error on WebSocket.cpp
The following build commands failed: CompileC build/cocos2d_libs.build/Release-iphonesimulator/libcocos2d\ iOS.build/Objects-normal/i386/WebSocket.o /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp normal i386 c++ com.apple.compilers.llvm.clang.1_0.compiler
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:104:38: error: ISO C++
forbids forward references to 'enum' types
enum libwebsocket_callback_reasons reason,
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:104:68: error: variable has
incomplete type 'enum libwebsocket_callback_reasons'
enum libwebsocket_callback_reasons reason,
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:104:38: note: forward
declaration of 'cocos2d::network::libwebsocket_callback_reasons'
enum libwebsocket_callback_reasons reason,
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:108:45: error: use of
undeclared identifier 'libwebsocket_context_user'
WebSocket* wsInstance = (WebSocket*)libwebsocket_context_user(ctx);
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:251:33: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
for (int i = 0; _wsProtocols[i].callback != nullptr; ++i)
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:253:42: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name);
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:36:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../cocos/platform/CCPlatformMacros.h:215:45: note:
expanded from macro 'CC_SAFE_DELETE_ARRAY'
#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:253:42: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name);
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:36:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../cocos/platform/CCPlatformMacros.h:215:60: note:
expanded from macro 'CC_SAFE_DELETE_ARRAY'
#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:253:42: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
CC_SAFE_DELETE_ARRAY(_wsProtocols[i].name);
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:36:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../cocos/platform/CCPlatformMacros.h:215:65: note:
expanded from macro 'CC_SAFE_DELETE_ARRAY'
#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:255:2: warning: deleting
pointer to incomplete type 'struct libwebsocket_protocols' may cause undefined behavior
[-Wdelete-incomplete]
CC_SAFE_DELETE_ARRAY(_wsProtocols);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:36:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../cocos/platform/CCPlatformMacros.h:215:50: note:
expanded from macro 'CC_SAFE_DELETE_ARRAY'
#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = nullptr; } } while(0)
^ ~~~
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:312:21: error: allocation of
incomplete type 'libwebsocket_protocols'
_wsProtocols = new libwebsocket_protocols[protocolCount+1];
^~~~~~~~~~~~~~~~~~~~~~
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:313:26: error: invalid
application of 'sizeof' to an incomplete type 'libwebsocket_protocols'
memset(_wsProtocols, 0, sizeof(libwebsocket_protocols)*(protocolCount+1));
^ ~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:322:25: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
_wsProtocols[i].name = name;
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:323:25: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
_wsProtocols[i].callback = WebSocketCallbackWrapper::onSocketCallback;
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:330:21: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
_wsProtocols[0].name = name;
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:331:21: error: subscript of
pointer to incomplete type 'struct libwebsocket_protocols'
_wsProtocols[0].callback = WebSocketCallbackWrapper::onSocketCallback;
~~~~~~~~~~~~^
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:30:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.h:41:8: note: forward
declaration of 'libwebsocket_protocols'
struct libwebsocket_protocols;
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:403:9: error: use of
undeclared identifier 'libwebsocket_context_destroy'; did you mean 'lws_context_destroy'?
libwebsocket_context_destroy(_wsContext);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lws_context_destroy
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:41:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../external/websockets/include/ios/libwebsockets.h:1398:1: note:
'lws_context_destroy' declared here
lws_context_destroy(struct lws_context *context);
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:403:38: error: cannot
initialize a parameter of type 'struct lws_context *' with an lvalue of type
'struct libwebsocket_context *'
libwebsocket_context_destroy(_wsContext);
^~~~~~~~~~
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:41:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../external/websockets/include/ios/libwebsockets.h:1398:41: note:
passing argument to parameter 'context' here
lws_context_destroy(struct lws_context *context);
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:410:9: error: use of
undeclared identifier 'libwebsocket_service'
libwebsocket_service(_wsContext, 0);
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:434:17: error: assigning to
'const struct lws_protocols *' from incompatible type 'struct libwebsocket_protocols *'
info.protocols = _wsProtocols;
^ ~~~~~~~~~~~~
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:436:20: error: use of
undeclared identifier 'libwebsocket_get_internal_extensions'
info.extensions = libwebsocket_get_internal_extensions();
^
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:442:15: error: use of
undeclared identifier 'libwebsocket_create_context'; did you mean 'lws_create_context'?
_wsContext = libwebsocket_create_context(&info);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
lws_create_context
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/network/WebSocket.cpp:41:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/build/../external/websockets/include/ios/libwebsockets.h:1392:1: note:
'lws_create_context' declared here
lws_create_context(struct lws_context_creation_info *info);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
I have replaced WebSocket.cpp and WebSocket.h but there is error on lua-bindings.
I think it would have error on js-bindings too as you said it breaks compatibility.
Any solution?
In file included from /Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/scripting/lua-bindings/manual/network/Lua_web_socket.h:37:
/Applications/Cocos/frameworks/cocos2d-x-3.8.1/cocos/scripting/lua-bindings/proj.ios_mac/../../../network/WebSocket.h:37:10: fatal error:
'libwebsockets.h' file not found
#include "libwebsockets.h"
^
1 error generated.