Fix error when sending empty name to unnamed game update players
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
c2f8e74265
commit
62489e925f
@ -3161,18 +3161,24 @@ const sendUpdateToPlayers = async (game, update) => {
|
|||||||
update
|
update
|
||||||
});
|
});
|
||||||
for (let key in game.sessions) {
|
for (let key in game.sessions) {
|
||||||
const _session = game.sessions[key];
|
const session = game.sessions[key];
|
||||||
/* Only send player and game data to named players */
|
/* Only send player and game data to named players */
|
||||||
if (!_session.name) {
|
if (!session.name) {
|
||||||
console.log(`${session.id}: -> sendUpdateToPlayers:` +
|
console.log(`${session.id}: -> sendUpdateToPlayers:` +
|
||||||
`${getName(_session)} - only sending empty name`);
|
`${getName(session)} - only sending empty name`);
|
||||||
message = JSON.stringify({ name: "" });
|
if (session.ws) {
|
||||||
|
session.ws.send(JSON.stringify({
|
||||||
|
type: 'game-update',
|
||||||
|
update: { name: "" }
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
if (!_session.ws) {
|
continue;
|
||||||
|
}
|
||||||
|
if (!session.ws) {
|
||||||
console.log(`${_session.id}: -> sendUpdateToPlayers: ` +
|
console.log(`${_session.id}: -> sendUpdateToPlayers: ` +
|
||||||
`Currently no connection.`);
|
`Currently no connection.`);
|
||||||
} else {
|
} else {
|
||||||
_session.ws.send(message);
|
session.ws.send(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user