Refactor server-side lobby code

Most of the lobby logic has now been moved into its own file.  app.js is
still responsible for handling socket.io connections, but it mostly just
calls lobby.js functions.