title: Socket.io + Express: Different events/functions for different routes
body: <p>Well ... I got my first express + socketio node App up and running.</p>
  
  <p>Socketio is used on almost every single page in my app because all the "lists" showed on those pages should be updated with server-push when new entries are added.</p>
  
  <p>So I got my main app.js File + a routes dir with all the route.js files in it.
  Now I need different socketio events + functions for each route since different things happen on those pages.</p>
  
  <p>Question now is how do I access my express server for initializing the socketio object?</p>
  
  <pre><code>// app.js
  var server = app.listen(app.get('port'), function(){...});
  var io = socketio.listen(server);
  // socket.io code here
  // the code from here on should be different for each route.js file
  </code></pre>
  
  <p>or in other words:</p>
  
  <p>How can I exclude all my event and function definitions for socket.io into the corresponding route files so different socket.io events and functions are defined for each page?
  The socket can of course always run on the same port (I hope that's no problem?!).</p>
  
  <p>I hope that was understandable ... a bit difficult to explain.</p>
  
  <p>best regards
  Patrick</p>