return uapi_ws_send_text(text);
}
-// int ln_ws_send_random_story_cache(const char *story_theme)
-// {
-
-// }
+int ln_ws_send_random_story_cache(const char *story_theme)
+{
+ memcpy(story_theme_cache,story_theme,strlen(story_theme));
+ return 0;
+}
/* 发送随机故事请求 */
int ln_ws_send_random_story_request(const char *story_theme)
{
return -1;
}
- if (g_ws_connected != WS_STATE_CONNECTED) {
+
+ ln_ws_send_voice_chat_interrupt("故事请求开始");
+
+ if (g_ws_connected == WS_STATE_RECONNECTING) {
+ // 重连中,缓存音频数据
+ LN_WS_INFO("Connection reconnecting,ln_ws_send_random_story_request data (%s)\n", story_theme);
+ return ln_ws_send_random_story_cache(story_theme);
+ }
+ else if (g_ws_connected != WS_STATE_CONNECTED) {
LN_WS_WARN("Cannot send random story request, connection state: %d\n", g_ws_connected);
return -1;
}
- // ln_ws_send_voice_chat_interrupt("故事请求开始");
-
- // if (g_ws_connected == WS_STATE_RECONNECTING) {
- // // 重连中,缓存音频数据
- // LN_WS_INFO("Connection reconnecting,ln_ws_send_random_story_request data (%s)\n", story_theme);
- // return ln_ws_audio_buffer_add(audio_data, audio_size, finished);
- // }
-
// 生成聊天ID(使用当前对话ID)
generate_chat_id(g_audio_chat_ctx.chat_id, sizeof(g_audio_chat_ctx.chat_id));
- // g_audio_chat_ctx.finish_state = LN_CHAT_SENT_END_NO_REPLY;
+ g_audio_chat_ctx.finish_state = LN_CHAT_SENT_END_NO_REPLY;
// 生成消息ID
char message_id[128];
g_ws_connected = WS_STATE_CONNECTED;
-
+ if(strlen(story_theme_cache)>3)
+ {
+ ln_ws_send_random_story_request(story_theme_cache);
+ memset(story_theme_cache,0,sizeof(story_theme_cache));
+ }
LN_WS_INFO("Reconnect success event triggered\n");
}