Rewrite in an EventEmitter style.

This is based on https://github.com/bnoordhuis/node-event-emitter and
simplifies the interface (at least to me).  Support connecting and
disconnecting, and displaying incoming message types.