Refactor websocket connector