update:优化超时资源优化

This commit is contained in:
hrz
2025-06-27 23:38:05 +08:00
parent f8ccc7a92f
commit 6f6c39da23
4 changed files with 30 additions and 26 deletions
@@ -66,12 +66,11 @@ async def startToChat(conn, text):
async def no_voice_close_connect(conn, have_voice):
if have_voice:
conn.client_no_voice_last_time = 0.0
conn.last_activity_time = time.time() * 1000
return
if conn.client_no_voice_last_time == 0.0:
conn.client_no_voice_last_time = time.time() * 1000
else:
no_voice_time = time.time() * 1000 - conn.client_no_voice_last_time
# 只有在已经初始化过时间戳的情况下才进行超时检查
if conn.last_activity_time > 0.0:
no_voice_time = time.time() * 1000 - conn.last_activity_time
close_connection_no_voice_time = int(
conn.config.get("close_connection_no_voice_time", 120)
)
@@ -93,7 +93,7 @@ async def sendAudio(conn, audios, pre_buffer=True):
break
# 重置没有声音的状态
conn.client_no_voice_last_time = 0.0
conn.last_activity_time = time.time() * 1000
# 计算预期发送时间
expected_time = start_time + (play_position / 1000)