Skip to content

Commit

Permalink
Fix possible invariant state.
Browse files Browse the repository at this point in the history
  • Loading branch information
vldr committed Jun 17, 2023
1 parent 96bfed9 commit 1bb5bd1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ impl Client
}

let room_id = Uuid::new_v4().to_string();
self.room_id = Some(room_id.clone());

if server.rooms.contains_key(&room_id)
{
return self.sender.send_error_packet("A room with that identifier already exists.".to_string());
}

let mut room = Room::new(size);
room.senders.push(self.sender.clone());
server.rooms.insert(room_id.clone(), room);

server.rooms.insert(room_id.clone(), room);

self.room_id = Some(room_id.clone());
self.sender.send_packet(ServerPacket::Create { id: room_id })
}

Expand Down

0 comments on commit 1bb5bd1

Please sign in to comment.