Support websockets

This PR refactors the code from #58 to work with the latest version of web.