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

  1. Add the highlighted code in the src/index.js file:

Get hands-on with 1200+ tech skills courses.