长连接游戏,只要消息一多,客户端异常的卡。经过测试服务器不是问题,于是给客户端做了个测试:
pomelo服务器,连续发100个消息给客户端。服务器log显示花费了130ms左右的时间。
用pomelo-client写网页测试,从收到第1个消息到收到第100个消息,中间隔了130ms
用cocos2d-js-html5版测试,从收到第1个消息到收到第100个消息,中间隔了160ms
用cocos2d-jsb版,在iphone5上测试,从收到第1个消息到收到第100个消息,中间隔了3000ms
3000ms啊。。。
PS:cocos2d-js版本是3.3,客户端用了pomelo-cocos2d-js,内网测试,测试中只统计时间没有做任何逻辑:代码如下
var _testList = ];
var _startTime, _endTime;
window.pomelo.notify('connector.entryHandler.startTestWeb');
window.pomelo.on('testWebsocket', function (data) {
if(_testList.length ===0) {
_startTime = new Date().getTime();
}
_testList.push(data.data);
if(_testList.length === 100) {
_endTime = new Date().getTime();
cc.log('receive web used:', _endTime - _startTime);
}
});
```