server for my chess game
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js
index 06818c5..c0068b6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -97,8 +97,10 @@ function handle_hostrequest(data, ws) {
function handle_stop(data) {
console.log("stopgame " + data);
- games[data].forEach((client) => {
- send_packet("", HEADERS.stopgame, client);
- });
- delete games[data];
+ if (games[data] !== undefined) {
+ games[data].forEach((client) => {
+ send_packet("", HEADERS.stopgame, client);
+ });
+ delete games[data];
+ }
}