public async Task RequestRandomRoom(int betChoice, int capacityChoice, ActiveUser activeUser) { if (!betChoice.IsInRange(Room.Bets.Length) || !capacityChoice.IsInRange(Room.Capacities.Length)) { throw new BadUserInputException(); } var dUser = await _masterRepo.GetUserByIdAsyc(activeUser.Id); if (dUser.Money < Room.Bets[betChoice]) { throw new BadUserInputException(); } var room = TakeOrCreateAppropriateRoom(betChoice, capacityChoice); var roomUser = CreateRoomUser(activeUser, room); room.RoomUsers.Add(roomUser); room.RoomActors.Add(roomUser); RemoveDisconnectedUsers(room); if (room.IsFull) { _serverLoop.CancelPendingRoomTimeout(room); await PrepareRoom(room); } else { activeUser.Domain = typeof(UserDomain.App.Lobby.Pending); _serverLoop.SetupPendingRoomTimeoutIfNotExist(room); _sessionRepo.KeepPendingRoom(room); } }