Improvements

This commit is contained in:
MaciejkaG 2024-04-07 00:07:11 +02:00
parent fd9c4a8ea7
commit 8969d6242e

View File

@ -444,7 +444,7 @@ io.on('connection', async (socket) => {
// Teraz utwórz objekt partii w trakcie w bazie Redis // Teraz utwórz objekt partii w trakcie w bazie Redis
const gameId = uuidv4(); const gameId = uuidv4();
redis.json.set(`game:${gameId}`, '$', { redis.json.set(`game:${gameId}`, '$', {
hostId: opp.request.session.id, hostId: opp.request.session.userId,
state: "pregame", state: "pregame",
startTs: (new Date()).getTime() / 1000, startTs: (new Date()).getTime() / 1000,
ready: [false, false], ready: [false, false],
@ -522,7 +522,7 @@ io.on('connection', async (socket) => {
for (let i = 0; i < members.length; i++) { for (let i = 0; i < members.length; i++) {
const sid = members[i][0]; const sid = members[i][0];
const socket = io.sockets.sockets.get(sid); const socket = io.sockets.sockets.get(sid);
if (socket.session.id === playerGame.data.hostId) { if (socket.request.session.userId === playerGame.data.hostId) {
io.to(sid).emit('player idx', 0); io.to(sid).emit('player idx', 0);
} else { } else {
io.to(sid).emit('player idx', 1); io.to(sid).emit('player idx', 1);