Make it possible to combine --server --client

This commit is contained in:
JustArchi
2016-11-13 15:51:35 +01:00
parent 10dbec9a67
commit cba64531fa
3 changed files with 28 additions and 28 deletions

View File

@@ -229,6 +229,30 @@ namespace ArchiSteamFarm {
}
}
internal static void InitBots() {
if (Bot.Bots.Count != 0) {
return;
}
// Before attempting to connect, initialize our list of CMs
Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider);
foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
switch (botName) {
case SharedInfo.ASF:
case "example":
case "minimal":
continue;
}
new Bot(botName).Forget();
}
if (Bot.Bots.Count == 0) {
ArchiLogger.LogGenericWarning("No bots are defined, did you forget to configure your ASF?");
}
}
internal static void InitFileWatcher() {
if (FileSystemWatcher != null) {
return;

View File

@@ -230,6 +230,7 @@ namespace ArchiSteamFarm {
case "--server":
Mode |= EMode.Server;
WCF.StartServer();
ASF.InitBots();
break;
default:
if (arg.StartsWith("--", StringComparison.Ordinal)) {
@@ -334,33 +335,8 @@ namespace ArchiSteamFarm {
Exit();
}
// From now on it's server mode
if (!Directory.Exists(SharedInfo.ConfigDirectory)) {
ASF.ArchiLogger.LogGenericError("Config directory doesn't exist!");
Thread.Sleep(5000);
Exit(1);
}
ASF.CheckForUpdate().Wait();
// Before attempting to connect, initialize our list of CMs
Bot.InitializeCMs(GlobalDatabase.CellID, GlobalDatabase.ServerListProvider);
foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension)) {
switch (botName) {
case SharedInfo.ASF:
case "example":
case "minimal":
continue;
}
new Bot(botName).Forget();
}
if (Bot.Bots.Count == 0) {
ASF.ArchiLogger.LogGenericWarning("No bots are defined, did you forget to configure your ASF?");
}
ASF.InitBots();
ASF.InitFileWatcher();
}

View File

@@ -87,7 +87,7 @@ namespace ArchiSteamFarm {
}
internal void StartServer() {
if (ServiceHost != null) {
if (IsServerRunning) {
return;
}
@@ -113,7 +113,7 @@ namespace ArchiSteamFarm {
}
internal void StopServer() {
if (ServiceHost == null) {
if (!IsServerRunning) {
return;
}