fix first WebSocket connection

This commit is contained in:
Raphaël Jakse 2020-10-07 21:30:04 +02:00
parent 85b0bd04a0
commit 930fc12939
1 changed files with 5 additions and 2 deletions

View File

@ -446,9 +446,12 @@ function countTiles(rack) {
return count;
}
function joinGame(gameNumber) {
function joinGame(gameNumber, message) {
if (!gameNumber) {
gameNumber = newGameId();
if (message) {
message.gameNumber = gameNumber;
}
}
const game = games[gameNumber] || (games[gameNumber] = new Game());
@ -719,7 +722,7 @@ function handleCommand(cmdNumber, message, response) {
function handleCommands(message, responseAndType) {
if (!message.cmds || !message.cmds.length) {
const {gameNumber, game} = joinGame(message.gameNumber);
const {gameNumber, game} = joinGame(message.gameNumber, message);
writeMessage(responseAndType,
JSON.stringify({