Add Socket connection state hooks for browser client. Closes #405