Factor out WebSocket code into SocketClient class

This will allow us to implement reliable messages.
#35