feat: 用 SSE 替代 SWR 轮询,实现房间状态实时推送
SSE 断连时自动降级为 2s 轮询,重连后切回 SSE。
This commit is contained in:
@@ -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,
|
||||
@@ -52,6 +53,8 @@ export async function POST(
|
||||
);
|
||||
}
|
||||
|
||||
notify(id);
|
||||
|
||||
return NextResponse.json({
|
||||
match: updated.match,
|
||||
likeCount: updated.likes[rid]?.length ?? 0,
|
||||
|
||||
Reference in New Issue
Block a user