From 06fa098fe0bf70c8b6ac3b241d907035433cd588 Mon Sep 17 00:00:00 2001 From: tanjianbin <632190820@qq.com> Date: Wed, 25 Mar 2026 18:26:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91=EF=BC=8C=E9=87=87?= =?UTF-8?q?=E7=94=A8=E9=9D=9E=E9=98=BB=E5=A1=9E=E6=96=B9=E6=A1=88A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除发送消息后的固定等待时间,改为立即返回主页继续检测下一条消息。这避免了因等待造成的消息处理延迟,提高了消息处理吞吐量。 --- .../worktool/service/WeworkLoopImpl.kt | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt index 6cb1d87..f4bb9d1 100644 --- a/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt +++ b/app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt @@ -364,6 +364,7 @@ object WeworkLoopImpl { } } //推测是否回复并在房间等待指令 + // 方案A:发送消息后立即返回主页,继续检测下一条消息,不等待 if (needInfer) { val lastMessage = messageList.lastOrNull() if (lastMessage != null && lastMessage.sender == 0) { @@ -380,27 +381,14 @@ object WeworkLoopImpl { || tempContent.isNotBlank() ) { LogUtils.v("推测需要回复: $tempContent") - WeworkController.waitingForReply = true - val startTime = System.currentTimeMillis() - var currentTime = startTime - while (mainLoopRunning && currentTime - startTime < timeout) { - sleep(Constant.POP_WINDOW_INTERVAL / 5) - currentTime = System.currentTimeMillis() - } - WeworkController.waitingForReply = false - return getChatMessageList(needInfer = false, titleList = titleList) + // 方案A:不清空 waitingForReply,直接返回主页 + // 这样主循环会继续检测下一条消息 + return true } } 2 -> { - WeworkController.waitingForReply = true - val startTime = System.currentTimeMillis() - var currentTime = startTime - while (mainLoopRunning && currentTime - startTime < timeout) { - sleep(Constant.POP_WINDOW_INTERVAL / 5) - currentTime = System.currentTimeMillis() - } - WeworkController.waitingForReply = false - return getChatMessageList(needInfer = false, titleList = titleList) + // 方案A:不清空 waitingForReply,直接返回主页 + return true } else -> return true }