(app_status)
return client
Creates and returns a RAMP client based on the supplied app status.
    Will return None if RAMP client is not supported.
    Will raise ValueError if unable to retrieve the websocket url.
Creates and returns a RAMP client based on the supplied app status.
    Will return None if RAMP client is not supported.
    Will raise ValueError if unable to retrieve the websocket url.
Creates and returns a RAMP client based on the supplied app status . Will return None if RAMP client is not supported . Will raise ValueError if unable to retrieve the websocket url .
def create_websocket_client(app_status):
    """
    Creates and returns a RAMP client based on the supplied app status.
    Will return None if RAMP client is not supported.
    Will raise ValueError if unable to retrieve the websocket url.
    """

    # Check if current app has no service url or no protocols.
    if not app_status.service_url or not app_status.service_protocols:
        return None

    req = requests.post(app_status.service_url,
                        data="{}".encode("ascii"),
                        headers={"Content-Type": "application/json"})

    if req.status_code != 200:
        raise error.ConnectionError(
            "Could not retrieve websocket url ({}).".format(req.status_code))

    conn_data = json.loads(req.text)

    client = ChromecastWebSocketClient(conn_data['URL'],
                                       app_status.service_protocols)

    client.connect()

    atexit.register(_clean_open_clients)

    return client
def create_websocket_client ( app_status ) : # Check if current app has no service url or no protocols. if not app_status . service_url or not app_status . service_protocols : return None req = requests . post ( app_status . service_url , data = "{}" . encode ( "ascii" ) , headers = { "Content-Type" : "application/json" } ) if req . status_code != 200 : raise error . ConnectionError ( "Could not retrieve websocket url ({})." . format ( req . status_code ) ) conn_data = json . loads ( req . text ) client = ChromecastWebSocketClient ( conn_data [ 'URL' ] , app_status . service_protocols ) client . connect ( ) atexit . register ( _clean_open_clients ) return client