feat(multiplayer): replace polling with server-sent events and redis pub/sub

This commit is contained in:
jessy-david-dev
2026-04-14 16:00:09 +02:00
parent 7ecf268191
commit 90b14919c5
6 changed files with 194 additions and 40 deletions
+3
View File
@@ -4,6 +4,7 @@
import { NextRequest } from "next/server";
import type { Room, Player } from "../route";
import { prisma } from "../../../../lib/prisma";
import { redis, roomChannel } from "../../../../lib/redis";
function dbToRoom(row: {
code: string;
@@ -498,4 +499,6 @@ async function saveRoom(room: Room) {
roundStart: room.roundStart !== null ? BigInt(room.roundStart) : null,
},
});
// Notifie tous les clients SSE abonnés à cette room
await redis.publish(roomChannel(room.code), JSON.stringify(room));
}