fix first WebSocket connection
This commit is contained in:
parent
85b0bd04a0
commit
930fc12939
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue