mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 04:42:55 +01:00
Improvements
This commit is contained in:
parent
fd9c4a8ea7
commit
8969d6242e
4
index.js
4
index.js
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user