create class to handle both websocket connection and resource management