我使用下面的代码来运行服务器端套接字
var http = require('http');
var io = require('socket.io');
io.set('destroy upgrade',false);
var server = http.createServer(function(req, res){
// Send HTML headers and message
res.writeHead(200,{ 'Content-Type': 'text/html' });
res.end('<h1>Hello !</h1>');
});
server.listen(8080);
var socket = io.listen(server);
socket.on('connection', function(client){
client.on('message',function(event){
console.log('Received message from client!',event);
});
client.on('disconnect',function(){
console.log('Server has disconnected');
});
});
但它总是报告
typeError: Object #<Object> has no method 'set'
如果我删除该行
io.set('destroy upgrade',false);
它会起作用,但上面的行对我来说是必要的
欢迎您的评论