Hi:
I’m using the v2.1.4 cocos2d-html5.And it begins support websocket.
Then I began to write server through node.js and socket.io.
Before I start , I wrote a simple server as below:
`var app = require(‘http’).createServer(handler);
app.listen(1000);
var io = require(‘socket.io’).listen(app);
//io.set(“destroy upgrade” ,false);
function handler (req, res) {
res.writeHead(200, { ‘Content-Type’: ‘text/html’ });
res.end(‘Hello World\n’);
}
io.sockets.on(‘connection’, function(socket){
console.log(“Connection " + socket.id + " accepted.”);
socket.on(‘message’, function(message){
console.log("Received message: " + message + " - from client " + socket.id);
});
socket.on(‘disconnect’, function(){
console.log(“Connection " + socket.id + " terminated.”);
});
});`
Then I changed the code in WebSocketTest.js(provided in ExtensionTest/NetworkTest).
this._wsiSendText = new WebSocket(“ws://localhost:1000”); //the code I changed*
And when I run this test in chrome, chrome console said it couldn’t connet to server ‘localhost:1000’.
And the cmd of running server said ‘debug-destroying non-socket.io upgrade’.
Why?