refactor

this refactors a connections responsibilities so it can be re-used for Reader/Writer.  It introduces events on messages and connections for cleaner separation and testability.