Permalink
Browse files

real time game adds dashboard

  • Loading branch information...
1 parent 0809728 commit 8db069a538193639c41e8bfbd9ec4bd62603e5db @dwcares committed Sep 16, 2015
Showing with 13 additions and 7 deletions.
  1. +7 −6 app.js
  2. +5 −0 dashboard/dashboard.css
  3. +1 −1 public/default.js
View
@@ -35,7 +35,8 @@ io.on('connection', function(socket) {
});
}
- socket.emit('login', {users: Object.keys(lobbyUsers), games: Object.keys(users[userId].games)});
+ socket.emit('login', {users: Object.keys(lobbyUsers),
+ games: Object.keys(users[userId].games)});
lobbyUsers[userId] = socket;
socket.broadcast.emit('joinlobby', socket.userId);
@@ -66,6 +67,8 @@ io.on('connection', function(socket) {
delete lobbyUsers[game.users.white];
delete lobbyUsers[game.users.black];
+
+ socket.broadcast.emit('gameadd', {gameId: game.id, gameState:game});
});
socket.on('resumegame', function(gameId) {
@@ -84,7 +87,8 @@ io.on('connection', function(socket) {
}
if (lobbyUsers[game.users.black]) {
- lobbyUsers[game.users.black] && lobbyUsers[game.users.black].emit('joingame', {game: game, color: 'black'});
+ lobbyUsers[game.users.black] &&
+ lobbyUsers[game.users.black].emit('joingame', {game: game, color: 'black'});
delete lobbyUsers[game.users.black];
}
});
@@ -115,10 +119,7 @@ io.on('connection', function(socket) {
socket.on('dashboardlogin', function() {
console.log('dashboard joined');
-
- socket.gameses = ["hi", "hi"];
- socket.emit('dashboardlogin', {games: activeGames});
-
+ socket.emit('dashboardlogin', {games: activeGames});
});
});
@@ -5,4 +5,9 @@
body {
background-color: lightblue;
overflow-y: auto;
+}
+
+#games {
+ display: flex;
+ flex-flow: row wrap;
}
View
@@ -49,7 +49,7 @@
});
socket.on('move', function (msg) {
- if (msg.gameId === serverGame.id) {
+ if (serverGame && msg.gameId === serverGame.id) {
game.move(msg.move);
board.position(game.fen());
}

0 comments on commit 8db069a

Please sign in to comment.