io.set('authorization’, function(handshakeData, accept) { 设置了session 但是 io.sockets.on('connection’, function (socket) { 这里的soket的handshake里面没有session信息
为什么?大神帮忙下
4 回复
不是应该socket去set和get吗
//服务端 var io = require(‘socket.io’).listen(80); io.sockets.on('connection’, function (socket) { socket.on('set nickname’, function (name) { socket.set('nickname’, name, function () { socket.emit(‘ready’); }); }); socket.on('msg’, function () { socket.get('nickname’, function (err, name) { console.log('Chat message by ', name); }); }); });