Created
August 19, 2012 20:08
-
-
Save xmen4u/3397357 to your computer and use it in GitHub Desktop.
node.js + redis + socket.io + should work but doesn't (express's prefix bug?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
io.configure(function() { | |
io.set('authorization', function(handshakeData, callback) { | |
if (handshakeData.headers.cookie) { | |
req_cookie = cookie.parse(decodeURIComponent(handshakeData.headers.cookie)); | |
req_session = parseSignedCookie(req_cookie['connect.sid'], SECRET); | |
sessionStore.get(req_cookie['connect.sid'], function(err, session) { | |
if (session) { | |
req = { | |
sessionStore: sessionStore, | |
sessionID: handshakeData.sessionID | |
}; | |
session = new express.session.Session(req, session); | |
console.log(JSON.stringify(session)); | |
//handshakeData.session = new Session(handshakeData, session); | |
} | |
if (err || !session) { | |
console.log(JSON.stringify(session)); | |
console.log(JSON.stringify(err)); | |
console.log( 'Error!!!'); | |
return callback(err, false); | |
} | |
else { | |
handshakeData.session = new Session(data, session); | |
return callback(null, true); | |
} | |
}); | |
} else { | |
return callback('No cookie transmitted', false); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment