add support for socket.io 1.0

This commit is contained in:
José F. Romaniello
2014-06-03 08:12:07 -03:00
parent 0577d07b47
commit e8380c10b8
2 changed files with 25 additions and 8 deletions

View File

@@ -41,11 +41,19 @@ The previous approach uses a second roundtrip to send the jwt, there is a way yo
var io = require("socket.io")(server);
var socketioJwt = require("socketio-jwt");
// set authorization for socket.io
//// With socket.io < 1.0 ////
io.set('authorization', socketioJwt.authorize({
secret: 'your secret or public key',
handshake: true
}));
//////////////////////////////
//// With socket.io >= 1.0 ////
io.use(socketioJwt.authorize({
secret: 'your secret or public key',
handshake: true
}));
///////////////////////////////
io.on('connection', function (socket) {
console.log('hello! ', socket.handshake.decoded_token.name);