Make \exit test pass only when the socket is ended
Extract functions from parseForCommands into a command array

Based on http://stackoverflow.com/q/7365027/708682 I made an array of
regex, function pairs. When the server receives a message it loops
through the array and tests each regex. If it matches it calls the
function paired with the regex. If it doesn't match, it just prints out
the message.

The functions have all been moved out of the server object, along with
several general functions which are useful outside of server. Fixes #2!
Name anonymous function callbacks

This means more typing but makes stack traces much more readable!