新增: 小程序端跨端AI对话

This commit is contained in:
2026-06-24 00:19:54 +08:00
parent 0c7c5e6068
commit 698d981962
20 changed files with 5647 additions and 1242 deletions

View File

@@ -247,6 +247,15 @@ async fn handle_connection(socket: WebSocket, state: RelayState, expected: Clien
"连接握手通过,进入收发循环"
);
// 握手通过:立即发 ack 控制帧给客户端。
// 客户端据此判定握手成功(首条非 error 消息即 handshaked),不依赖等待对端首条业务消息 ——
// 否则单端连入时(device 离线)relay 静默,客户端永卡 handshaking,send 被 handshaked 守卫拦截。
let _ = send_text(
&mut socket_tx,
r#"{"kind":"control","payload":{"control_kind":"hello_ack"}}"#,
)
.await;
// 建立广播投递 mpsc(连接读取任务消费 → 写回 socket)
let (bc_tx, bc_rx) = mpsc::unbounded_channel::<BroadcastMessage>();
let handle = ConnHandle::new(conn_id, kind, device_id.clone(), bc_tx);