diff --git a/packages/server/packages/play-node-go/server/data/migrations/20200120224032_game.js b/packages/server/packages/play-node-go/server/data/migrations/20200120224032_game.js index 53dde63..67c6a0e 100644 --- a/packages/server/packages/play-node-go/server/data/migrations/20200120224032_game.js +++ b/packages/server/packages/play-node-go/server/data/migrations/20200120224032_game.js @@ -36,8 +36,8 @@ exports.up = function(knex) { table.enu('win_type', winType); table.float('score'); - table.integer('black_captures'); - table.integer('white_captures'); + table.integer('captures_black'); + table.integer('captures_white'); table.integer('user_black').references('id').inTable('user'); table.integer('user_white').references('id').inTable('user'); diff --git a/packages/server/packages/play-node-go/server/data/queries/game.js b/packages/server/packages/play-node-go/server/data/queries/game.js index c8bebe1..5b846fc 100644 --- a/packages/server/packages/play-node-go/server/data/queries/game.js +++ b/packages/server/packages/play-node-go/server/data/queries/game.js @@ -4,7 +4,7 @@ const gameDetailSelect = [ 'game.id', 'application', 'application_version', 'board_size', 'komi', 'handicap', 'open', 'win_type', 'player_black', 'player_black_rank', 'player_white', 'player_white_rank', - 'black_captures', 'white_captures', 'score', 'win_type', + 'captures_black', 'captures_white', 'score', 'win_type', 'description', 'event', 'round', 'name', 'room' ] diff --git a/packages/server/packages/play-node-go/server/socket.js b/packages/server/packages/play-node-go/server/socket.js index 384358a..b218a4d 100644 --- a/packages/server/packages/play-node-go/server/socket.js +++ b/packages/server/packages/play-node-go/server/socket.js @@ -11,11 +11,18 @@ io.on('connection', socket=> { if (data.user && data.user.email) { delete data.user.email; } - const roomIo = io.of(data.room); + const room= data.room; + const roomIo = io.of(room); roomIo.on('connection', socket => { socket.emit('connected') socket.emit('new_user', data); - }) + socket.on('connect_game', data => { + const game = `game-${data.game.id}`; + socket.join(game, () => { + io.of(room).to(game).emit('game_connected', {}) + }); + }); + }); }) }) diff --git a/packages/server/packages/play-node-go/server/test/api.game.spec.js b/packages/server/packages/play-node-go/server/test/api.game.spec.js index bb3160d..df0c09d 100644 --- a/packages/server/packages/play-node-go/server/test/api.game.spec.js +++ b/packages/server/packages/play-node-go/server/test/api.game.spec.js @@ -15,8 +15,8 @@ const apiRoomSpec = (chai, knex, server) => { player_black_rank: 'UR', player_white: 'user-two', player_white_rank: 'UR', - black_captures: null, - white_captures: null, + captures_black: null, + captures_white: null, score: null, description: null, event: null,