Actions Required:
* Change calls to msg.prepare to msg.prepare_payload. For messages
with a user-defined Fields, provide the function prepare_payload_impl
in the fields type according to the Fields requirements.
fix#297, fix#488
* Errors are checked and reported
* More comments explaining what is going on
* The connection is gracefully closed
WebSocket:
* Messages are drained before closing