The old io.set() and io.get() methods are deprecated and only supported for backwards compatibility. Here is a translation of an old authorization example into middleware-style.
io.set(‘authorization’, function (handshakeData, callback) {
// make sure the handshake data looks good
callback(null, true); // error first, ‘authorized’ boolean second
});
vs.
io.use(function(socket, next) {
var handshakeData = socket.request;
// make sure the handshake data looks good as before
// if error do this:
// next(new Error(‘not authorized’);
// else just call next
next();
});
补充:安装socket.io@0.9版本,1.0版本中去掉了get和set方法,外加一个:nodejs + socket.io + redis 新手上路:http://www.cnblogs.com/aibo/p/3366925.html
自问自答吧,找到答案了,在官方文档里,被《nodejs高级编程》这本书坑了啊,都过时了。。:
socket.io官方文档