Your listen function is just returning another function and not actually triggering the code to setup socketio to listen.
Try:
module.exports.listen = function(app) {
io = socketio.listen(app);
io.sockets.on('connection', function (socket) {
socket.on('disconnect', function () {
if (socket.uid !== undefined) {
// do some stuff
}
});
});
return io;
};
Here's another example: https://github.com/paypal/kraken-js/issues/39