Created
February 27, 2013 11:09
-
-
Save 3rd-Eden/5047169 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
this.io = this.engine = new Engine.Server(); | |
// | |
// Handle WebSocket server upgrades, again, check if it's a valid request. | |
// BE-AWARE HERE BE DEMONS AND MONKEY PATCHES. | |
// - There is no way to re-using the middleware that is specified in | |
// | |
server.on('upgrade', function upgrade(req, socket, head) { | |
req.originalUrl = req.url; // connect compatibility | |
common.async.series([ | |
self.cookieParser.bind(self.cookieParser, req, socket) | |
, self.sessionStore.bind(self.sessionStore, req, socket) | |
], function finished() { | |
if (!req.session.loggedIn) return socket.end(); | |
self.engine.handleUpgrade(req, socket, head); | |
}); | |
}); | |
// Add the requestHandle to the connect/express middleware | |
connect.use(function (req, res, next) { | |
self.engine.handleRequest(req, res); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment