Skip to content

Instantly share code, notes, and snippets.

@mathieuhays
Created July 30, 2014 13:17
Show Gist options
  • Select an option

  • Save mathieuhays/46c65ce0a2aa2b9231e2 to your computer and use it in GitHub Desktop.

Select an option

Save mathieuhays/46c65ce0a2aa2b9231e2 to your computer and use it in GitHub Desktop.
Express.js - Get req, res value inside socket.io connection
var module = require('./module');
// ..... //
app.use( express.methodOverride() );
app.use( module.setup );
app.use( app.router );
// ..... //
io.on('connection', module.process );
var info;
module.exports.setup = function(req, res, next ){
// set info to whatever you like
next();
}
module.exports.process = function( socket ){
/handle stuff here
socket.on('something', function(){
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment