def METHOD_NAME(serve_asgi_adapter):
    received = Queue()
    @WebSocketRequest.listener
    def echo_headers(request: WebSocketRequest):
        with request.accept() as ws:
            ws.send(b"foo")
            ws.send("textfoo")
            received.put(ws.receive())
            received.put(ws.receive())
    server = serve_asgi_adapter(wsgi_app=None, websocket_listener=echo_headers)
    client = websocket.WebSocket()
    client.connect(server.url.replace("http://", "ws://"))
    assert client.handshake_response.status == 101
    data = client.recv()
    assert data == b"foo"
    data = client.recv()
    assert data == "textfoo"
    client.send("textbar")
    client.send_binary(b"bar")
    assert received.get(timeout=5) == "textbar"
    assert received.get(timeout=5) == b"bar"