Add a connected flag to fix double leave notify.

Closes #33.