stub game connection via socket room
This commit is contained in:
parent
1f89dbc481
commit
857e9e0fd5
4 changed files with 14 additions and 7 deletions
|
@ -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');
|
||||
|
|
|
@ -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'
|
||||
]
|
||||
|
||||
|
|
|
@ -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', {})
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue