Display Game Information
Learn how to broadcast messages and the current information of an ongoing game.
We'll cover the following...
We'll cover the following...
Next, use socket.broadcast.to to send a message event to let all other players in the room know when a new player has joined the game.
Task 7: Let players know a new player has joined with socket.broadcast.to
Next, we’ll use socket.broadcast.to to send a message event to let all other players in the room know when a new player has joined the game
- Add the highlighted code in the
src/index.jsfile:
- Join the same room from several browser tabs. We should see the chat box update with a new message about the player who has just joined every time a new socket connects to the server.