Created
July 30, 2014 13:17
-
-
Save mathieuhays/46c65ce0a2aa2b9231e2 to your computer and use it in GitHub Desktop.
Express.js - Get req, res value inside socket.io connection
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
| var module = require('./module'); | |
| // ..... // | |
| app.use( express.methodOverride() ); | |
| app.use( module.setup ); | |
| app.use( app.router ); | |
| // ..... // | |
| io.on('connection', module.process ); |
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
| 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