From 30c0acd6455dca3d8ba4654a04c0575447a22237 Mon Sep 17 00:00:00 2001 From: zakhy Date: Fri, 18 Apr 2025 13:19:40 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=87=D0=B8=D0=BD=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/workerslocation/commands/radiusip.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/workerslocation/commands/radiusip.py b/apps/workerslocation/commands/radiusip.py index fa80ed8..c6bd06d 100644 --- a/apps/workerslocation/commands/radiusip.py +++ b/apps/workerslocation/commands/radiusip.py @@ -82,7 +82,7 @@ async def receive_messages(websocket, auth_dict): source_id = auth_dict.get("client_id") waiting_for_grant = False current_voice_call = None - + promise_granted = False async for message in websocket: message_from_json = json.loads(message) for message_item in message_from_json: @@ -115,6 +115,14 @@ async def receive_messages(websocket, auth_dict): elif identifier == "core/promise_response" and waiting_for_grant: payload = message_item["payload"] if payload["state"] == "granted" and current_voice_call: + promise_granted = True + elif payload["state"] == "faulted": + log("[ОШИБКА] Передача отклонена сервером.") + waiting_for_grant = False + current_voice_call = None + elif identifier == 'call:1/participant_state_broadcast' and promise_granted: + payload = message_item["payload"] + if payload['state'] == 'own_tx': log("Разрешение получено. Начинаем трансляцию...") await set_voice_call_sent(current_voice_call) await start_audio_stream( @@ -123,16 +131,12 @@ async def receive_messages(websocket, auth_dict): voip_port, ssrc ) - await send_messages(websocket, get_promise_cancel_command(promise_id)) + await send_messages(websocket, + get_promise_cancel_command(promise_id)) log("Трансляция завершена и вызов остановлен.") promise_id += 1 waiting_for_grant = False current_voice_call = None - elif payload["state"] == "faulted": - log("[ОШИБКА] Передача отклонена сервером.") - waiting_for_grant = False - current_voice_call = None - elif call_mapi_initialized and auth_dict.get("plasystem") and not waiting_for_grant: voice_call = await get_voice_calls() if voice_call: