Add render loop timer and heartbeat logic.

The application can now detect connection state to the server. It
currently polls every 3 seconds to see if the server is reachable; if
not, it switches to offline mode (currently just a global flag
change). There's no exponential backoff in this change because the
server is local and we don't need to worry about slamming it.

This change also introduces better defined separation between rendering
and state management - no state changes should originate from render
functions, and state functions should not change UI.