title: Socket.io Best coding practice
body: <p>I'm developing a Node.js application which uses Socket.io to handle the real time communication. My code is full of On and Emit functions. I use room feature as well. my app looks like this: </p>
  
  <pre><code>   var server = require('http').Server();
      var io = require('socket.io')(server);
      io.on('connection', function(socket){
        socket.on('event1', function(data){"lots of socket and non-socket codes" });
        socket.on('event2', function(data){"lots of socket and non-socket codes" });
        socket.on('event3', function(data){"lots of socket and non-socket codes" });
        socket.on('disconnect', function(){"Some other code"});
      });
      server.listen(portNum); 
  </code></pre>
  
  <p>it works fine but It is not my ideal solution. 
  Firstly, in this approach everything is in one big file instead of smaller file with isolated functionality.</p>
  
  <p>secondly, it is quite difficult to debug and maintain this app as it is quite messy when it comes to 1000+ lines of code. </p>
  
  <p>Here is my question:</p>
  
  <p>Is there a preferred/best practice on developing enterprise quality Socke.io applications?
  If yes, Is there any large opensource Socket.io application that demonstrait this approch or any article which help me to refactor my code in a better fassion?</p>