title: Loading socket.io as a module in KrakenJS/Express
body: <p>I'm trying to seperate my socket.io code in my app to it's own file like the answer in this thread: <a href="https://stackoverflow.com/questions/9709912/separating-file-server-and-socket-io-logic-in-node-js">Separating file server and socket.io logic in node.js</a></p>
  
  <p>However, the socket.io code never runs and will not start to listen and I don't really understand why:</p>
  
  <pre><code>//index.js
  kraken.create(app).listen(function (err, server) {
          if (err) {
              console.error(err);
          }
          var io = require('./lib/socket').listen(server);
      });
  
  //socket.js
  var socketio = require('socket.io')
  
  module.exports.listen = function(app) {
      return function (req, res) {
          io = socketio.listen(app);
  
          io.sockets.on('connection', function (socket) {
  
              socket.on('disconnect', function () {
                  if (socket.uid !== undefined) {
                      // do some stuff
                  }
              });
          });
  
          return io;
      }
  };
  </code></pre>
  
  <p>My best guess is that the req and res objects doesn't exist since it's not a request? The problem is that I really need to use the req object since I need to access the session during connect. If this is the issue, how can achieve that?</p>
  
  <p>Thanks in advance for your sage advice and better wisdom.</p>
  
  <p><strong>EDIT:</strong> I have looked at <a href="https://github.com/jfromaniello/passport.socketio" rel="nofollow noreferrer">https://github.com/jfromaniello/passport.socketio</a> which is kinda exactly what I need, however I don't know what my session key or secret is. How can I know that with passport?</p>