Initial web socket API.

This PR is to a `websocket` feature branch for later merging into `master`.
Gotcha. I'd be tempted to omit sending pings from the API until somebody demands it of you!