CMs refresh has to be done only once

This commit is contained in:
JustArchi
2016-01-24 17:38:45 +01:00
parent 79b6fc8b17
commit d55c734718
2 changed files with 17 additions and 13 deletions

View File

@@ -120,6 +120,20 @@ namespace ArchiSteamFarm {
await Task.WhenAll(tasks).ConfigureAwait(false);
}
internal static void RefreshCMs() {
bool initialized = false;
while (!initialized) {
try {
Logging.LogGenericInfo("Main", "Refreshing list of CMs...");
SteamDirectory.Initialize().Wait();
initialized = true;
Logging.LogGenericInfo("Main", "Success!");
} catch (TaskCanceledException) {
Logging.LogGenericWarning("Main", "Failed! Retrying...");
}
}
}
internal Bot(string botName) {
if (Bots.ContainsKey(botName)) {
return;
@@ -190,19 +204,6 @@ namespace ArchiSteamFarm {
);
}
// Before attempting to connect, initialize our list of CMs
bool initialized = false;
while (!initialized) {
try {
Logging.LogGenericInfo(BotName, "Getting list of CMs...");
SteamDirectory.Initialize().Wait();
initialized = true;
Logging.LogGenericInfo(BotName, "Success!");
} catch (TaskCanceledException) {
Logging.LogGenericWarning(BotName, "Failed! Retrying...");
}
}
// Start
var handleCallbacks = Task.Run(() => HandleCallbacks());
var start = Task.Run(async () => await Start().ConfigureAwait(false));

View File

@@ -256,6 +256,9 @@ namespace ArchiSteamFarm {
Task.Run(async () => await Exit(1).ConfigureAwait(false)).Wait();
}
// Before attempting to connect, initialize our list of CMs
Bot.RefreshCMs();
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) {
string botName = Path.GetFileNameWithoutExtension(configFile);
Bot bot = new Bot(botName);