From 2c0653d001e15aa02b07bda877692a0baa97b2e4 Mon Sep 17 00:00:00 2001 From: Laney Smith Date: Tue, 16 Aug 2016 17:54:37 -0600 Subject: [PATCH 1/2] Complete set-user-info --- app.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 103e832..c46d3fe 100644 --- a/app.js +++ b/app.js @@ -44,11 +44,14 @@ io.on("connection", socket => { } } } - console.log('new-game data.gameId=', data.gameId); socket.join(data.gameId) - console.log('allGames=', allGames); - console.log('this games players=', allGames[data.gameId].players); - io.to(data.gameId).emit('player-joined', data, allGames[data.gameId]) + var userSpecificData = { + username: data.username, + role: 'picker', + gameId: data.gameId, + gameInfo: allGames[data.gameId] + } + io.to(socket.id).emit('set-user-info', userSpecificData) }) socket.on('join-game', function(data) { @@ -60,11 +63,16 @@ io.on("connection", socket => { } console.log('allGames=', allGames); console.log('this games players=', allGames[data.gameId].players); - - console.log("join-game data.gameId=", data.gameId); + console.log("io.sockets.adapter.rooms=", io.sockets.adapter.rooms); socket.join(data.gameId) - console.log("io.sockets.adapter.rooms=", io.sockets.adapter.rooms); - io.to(data.gameId).emit('player-joined', data, allGames[data.gameId]) // loop through players in that game & emit to only them + var userSpecificData = { + username: data.username, + role: 'player', + gameId: gameId + } + io.to(data.gameId).emit('player-joined', allGames[gameId]) // loop through players in that game & emit to only them + io.to(socket.id).emit('set-user-info', userSpecificData) + }) }); From 2e03e8dd32fac43636acded6189c12ac1cfcd5a3 Mon Sep 17 00:00:00 2001 From: Laney Smith Date: Tue, 16 Aug 2016 20:26:28 -0600 Subject: [PATCH 2/2] Still trying to fix the client side problem --- app.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index c46d3fe..d8c8fbf 100644 --- a/app.js +++ b/app.js @@ -61,18 +61,15 @@ io.on("connection", socket => { score: 0, currentRole: 'player' } - console.log('allGames=', allGames); - console.log('this games players=', allGames[data.gameId].players); - console.log("io.sockets.adapter.rooms=", io.sockets.adapter.rooms); socket.join(data.gameId) var userSpecificData = { username: data.username, role: 'player', gameId: gameId } - io.to(data.gameId).emit('player-joined', allGames[gameId]) // loop through players in that game & emit to only them io.to(socket.id).emit('set-user-info', userSpecificData) - + io.to(data.gameId).emit('player-joined', allGames[gameId]) + console.log("io.sockets.adapter.rooms=", io.sockets.adapter.rooms); }) });