feat: 用 SSE 替代 SWR 轮询,实现房间状态实时推送

SSE 断连时自动降级为 2s 轮询,重连后切回 SSE。
This commit is contained in:
2026-02-24 19:51:30 +08:00
parent f6949a062f
commit 8c0d89af6d
9 changed files with 223 additions and 71 deletions
+3
View File
@@ -1,5 +1,6 @@
import { NextResponse } from "next/server";
import { atomicUpdateRoom } from "@/lib/store";
import { notify } from "@/lib/roomEvents";
export async function POST(
req: Request,
@@ -36,6 +37,8 @@ export async function POST(
);
}
notify(id);
return NextResponse.json({ ok: true });
} catch (e) {
console.error("Failed to reset room:", e);