server for my chess game
Diffstat (limited to 'src/index.js')
| -rw-r--r-- | src/index.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/index.js b/src/index.js index 9e0b53c..e162943 100644 --- a/src/index.js +++ b/src/index.js @@ -190,8 +190,9 @@ function handle_joinrequest(data, ws) { if (game !== undefined) { if (game.players < 2) { // hoster is waiting for someone to join - game.add_client(ws, data); - ws.send_packet({ idx: game.joinerIndex }, HEADERS.joinrequest); // tell them what team they are + + const joiner_idx = game.add_client(ws, data); + ws.send_packet({ idx: joiner_idx }, HEADERS.joinrequest); // tell them what team they are game.send_group_packet(game.pgn, HEADERS.loadpgn); // hoster doesnt send a joinrequest, so tell it to load pgn too send_info(); console.log(`${data.name} joined ${data.gamecode}`); |