Moved chat client code to a separate js file.