Updated chat.js to match tutorial (mostly)

For heartbeat, we need to write doServerPoll next.