mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Make it possible to combine --server --client
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user