stub game connection via socket room

This commit is contained in:
Sorrel Bri 2020-01-29 17:01:46 -08:00 committed by sorrelbri
parent 6a5ae9cc71
commit e02746cb67
4 changed files with 14 additions and 7 deletions

View file

@ -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');

View file

@ -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'
]

View file

@ -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', {})
});
});
});
})
})

View file

@ -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,