Refactored class WebSocketImpl