cocos2d-x3.10 适配 IPV6

cocos 依赖的三方库涉及到 IPV6 问题的库为 curlwebsocket, cocos 自己提供的模块需要适配的有:

  1. HttpClient
  2. AssetsManagerEx
  3. SocketIO
  4. WebSocket
  5. Console
  6. ScriptingCore

如果你需要支持纯IPv6网络,只需要更新CURL和libwebsocket网络。

1. 下载 cocos2d-x-3rd-party-libs-bin

2. 更新 curl

拷贝解压出来的文件夹中的 curl 目录到cocos2d-x/external, 替换原来的 curl目录. 如果编译报错,则:

在 XCode 项目输找到 cocos2d_lib > external > curl > ios 目录上右键, 选择 Add Files to 'cocos2d_lib.xcodeproj':

image_1alkfv73t446cr3sc41r6r1hqj13.png-238.8kB

选中 libcrypto.a 和 libssl.a, targets 选择 libcocos2d iOS, 确定, 重新编译, 搞定.

3. 更新 websocket

和 curl 类似, 拷贝 cocos2d-x-3rd-party-libs 中的 websockets 目录到 cocos2d-x/external, 替换原来的 websockets 目录.

因为最新版的 websockets api 变化挺大, 所以我们需要使用 cocos 最新的WebSocket.h 和 WebSocket.cpp 替换 cocos2d-x/cocos/network 中的 WebSocket .

编译, 会有一处错误发生在 WebSocket::WebSocket() 中, 是和 Director::EVENT_RESET 相关的消息, 我们注释掉这段代码即可.

{
// reserve data buffer to avoid allocate memory frequently
_receivedData.reserve(WS_RESERVE_RECEIVE_BUFFER_SIZE);
if (__websocketInstances == nullptr)
{
__websocketInstances = new (std::nothrow) std::vector<WebSocket*>();
}

__websocketInstances->push_back(this);

// std::shared_ptr<std::atomic<bool>> isDestroyed = _isDestroyed;
// _resetDirectorListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(Director::EVENT_RESET, [this, isDestroyed](EventCustom*){
// if (*isDestroyed)
// return;
// close();
// });
}

 

 

转载于:https://www.cnblogs.com/ab0016/p/6751899.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值