Попытка починки

This commit is contained in:
zakhy 2025-04-18 13:19:40 +07:00
parent 78a5c642c3
commit 30c0acd645

View File

@ -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: