title: Does socket.io rooms share variables?
body: <p>im making a tictactoe game with socket.io and nodejs</p>
  
  <p>with <code>io.sockets.adapter.rooms</code>, you can get the room objects</p>
  
  <p>i want to set a "board" variable to a room. this is what i tried: </p>
  
  <pre><code>var rooms = io.sockets.adapter.rooms
  var defaultBoard = [[0,0,0],[0,0,0],[0,0,0]];  //the default tictactoe board. 1 is x, 2 is o
  var roomCreated = 0;
  io.on("connection", socket =&gt; {
    //this event is emitted when someone click the "Create game" button
    socket.on("createGame", () =&gt; {
      var roomToJoin = `room-${++roomCreated}`;
      socket.join(roomToJoin);
      rooms[roomToJoin][socket.id].myTurn = true // add a myTurn variable to the player
      rooms[roomToJoin].board = defaultBoard;
    })
    socket.on("joinGame", roomRequested =&gt; {
      if (rooms[roomRequested] &amp;&amp; rooms[roomRequested].length === 1) {
        socket.join(roomRequested);
        rooms[roomRequested][socket.id].myTurn = false //add a myTurn variable to the joiner
        socket.emit("joined", rooms[roomRequested].board);
      }
    });
    socket.on("playTurn", (row, col =&gt; {                     //emited when client click a tile
      Object.entries(rooms).forEach(e =&gt; {                   //loop through each room
        if (e[1].sockets[socket.id] &amp;&amp; e[1].board) {         //get the room the socket is in
          if (e[1].board[row][col] &amp;&amp; !e[1][socket.id].myTurn) return;//if the tile is filled or not my turn, do nothing
          rooms[e[0]][socket.id].myTurn = !myTurn            //its not my turn anymore
          rooms[e[0]].otherPlayer.myTurn = !rooms[e[0]].otherPlayer.myTurn //otherPlayer is a variable i defined
          rooms[e[0]].board[row][col] = tile;                //change the tile of the board of the room (tile is a defined variable, could be 1 or 2)
         //let the client know the server updated his board, and update his html tictactoe board
          socket.emit("newBoard", room.board);
        }
      });
    })
  }
  </code></pre>
  
  <p>the problem is, board is somehow shared between the room objects. even though i refreshed the page and create a new game, somehow i still see the same board.it was not a visual bug, i were sure because i logged the client room's board</p>
  
  <p>if there are any syntax errors or such errors, its because i might have copied the code wrong. i didnt paste the full code in.</p>