From ba101ffdf8efe69868c3fca4e38e663a13cc7c1c Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Thu, 25 Dec 2025 12:12:04 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=88=87=E6=8D=A2=E7=95=8C?= =?utf8?q?=E9=9D=A2=E7=9A=84=E4=BF=9D=E6=8A=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../thunderbird/src/ThunderBirdModel.cpp | 18 ++++++++++++++++++ .../thunderbird/src/ThunderBirdPresenter.cpp | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 1610c1e8e..10e2ab072 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -3163,6 +3163,15 @@ extern "C" { // 录音开始处理函数 void ThunderBirdModel::HandleAudioRecordingStart() { + // 检查 WebSocket 连接状态,如果正在重连,等待重连完成 + int wsState = ln_ws_get_connection_state(); + bool wsConnected = (wsState == 2); // WS_STATE_CONNECTED = 2 + + if (!wsConnected) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleDialogueFunction: WebSocket未连接(状态=%d),等待连接完成", wsState); + // WebSocket 未连接,不执行操作,避免状态混乱 + return; + } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingStart: 录音开始"); if(ThunderBirdDialogueView::GetInstance()->IsNormalEnd == false) { @@ -3212,6 +3221,15 @@ extern "C" { // return ;//需要vad的时候在处理 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingEnd: 录音结束"); + // 检查 WebSocket 连接状态,如果正在重连,等待重连完成 + int wsState = ln_ws_get_connection_state(); + bool wsConnected = (wsState == 2); // WS_STATE_CONNECTED = 2 + + if (!wsConnected) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleDialogueFunction: WebSocket未连接(状态=%d),等待连接完成", wsState); + // WebSocket 未连接,不执行操作,避免状态混乱 + return; + } // 检查是否正在退出对话模式,如果是则不应该跳转到播放界面 ThunderBirdPresenter* presenter = ThunderBirdPresenter::GetInstance(); if (presenter != nullptr && !presenter->isDialogueing) { diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index e3b44899c..b4faccc45 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -444,6 +444,16 @@ namespace OHOS ThunderBirdModel::GetInstance()->ClearAudioTextQueue(); ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); } else if(currentView == THUNDERBIRD_DIALOGUEVIEW && currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING) { + // 检查 WebSocket 连接状态,如果正在重连,等待重连完成 + int wsState = ln_ws_get_connection_state(); + bool wsConnected = (wsState == 2); // WS_STATE_CONNECTED = 2 + + if (!wsConnected) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleDialogueFunction: WebSocket未连接(状态=%d),等待连接完成", wsState); + // WebSocket 未连接,不执行操作,避免状态混乱 + return; + } + GraphicService::GetInstance()->PostGraphicEvent([]() { AI_ForceInterrupt(); ln_ws_end_audio_chat(); -- 2.17.1