Skip to content

Commit

Permalink
Rename roomsById to roomsByCode
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Jul 5, 2019
1 parent 16fd4c1 commit e09e7d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/server/room-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import Room from './room.js';
class RoomManager {

constructor() {
this.roomsById = {};
this.roomsByCode = {};
this.inactiveRooms = new Set();
this.pollForAbandonedRooms();
}

getRoom(roomCode) {
return this.roomsById[roomCode];
return this.roomsByCode[roomCode];
}

openRoom() {
Expand All @@ -20,20 +20,20 @@ class RoomManager {
players: [],
code: roomCode
});
this.roomsById[roomCode] = room;
this.roomsByCode[roomCode] = room;
return room;
}

closeRoom(room) {
this.inactiveRooms.delete(room);
delete this.roomsById[room.code];
delete this.roomsByCode[room.code];
}

obtainRoomCode() {
let roomCode;
do {
roomCode = this.generateRandomRoomCode();
} while (this.roomsById[roomCode]);
} while (this.roomsByCode[roomCode]);
return roomCode;
}

Expand Down

0 comments on commit e09e7d8

Please sign in to comment.