Socket.io with Flatiron

Flatiron is a framework maintained by the guys over at nodejitsu. It's great, I've moved most of my pet node projects over to it. This has been mostly painless, however I will say that hit some discomfort with configuring socket.io.

In retrospect, it's actually rather simple process. Let's look at some code.

The confusion (in my case, anyway) occurs because the server property of flatiron.app is only available after the start function has been explicitly called. This means that socket.io can only listen to the flatiron server after you've told it to start (when the server property is actually created).

It's okay if that sounds confusing, it tripped me up too. The solution is rather simple: set up socket.io after the server has started, like so:

I've submitted a related pull request with a good example of what the whole process looks like. Hopefully this will help eliminate further confusion.