Initial web socket API.

This PR is to a `websocket` feature branch for later merging into `master`.
Just wrote that. And I love it already. The symmetry is so nice.