General improvements

This commit is contained in:
JustArchi
2016-08-01 18:17:51 +02:00
parent 6977343906
commit d85d41c215
4 changed files with 59 additions and 76 deletions

View File

@@ -31,6 +31,9 @@ using System.ServiceModel.Description;
namespace ArchiSteamFarm {
[ServiceContract]
internal interface IWCF {
[OperationContract]
string GetStatus();
[OperationContract]
string HandleCommand(string input);
}
@@ -59,15 +62,15 @@ namespace ArchiSteamFarm {
return null;
}
if (Program.GlobalConfig.SteamOwnerID == 0) {
return "Refusing to handle request because SteamOwnerID is not set!";
}
Bot bot = Bot.Bots.Values.FirstOrDefault();
if (bot == null) {
return "ERROR: No bots are enabled!";
}
if (Program.GlobalConfig.SteamOwnerID == 0) {
return "Refusing to handle request because SteamOwnerID is not set!";
}
string command = "!" + input;
string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; // TODO: This should be asynchronous
@@ -75,6 +78,8 @@ namespace ArchiSteamFarm {
return output;
}
public string GetStatus() => Program.GlobalConfig.SteamOwnerID == 0 ? "{}" : Bot.GetAPIStatus();
public void Dispose() {
Client?.Close();
StopServer();
@@ -138,10 +143,10 @@ namespace ArchiSteamFarm {
}
}
internal sealed class Client : ClientBase<IWCF>, IWCF {
internal sealed class Client : ClientBase<IWCF> {
internal Client(Binding binding, EndpointAddress address) : base(binding, address) { }
public string HandleCommand(string input) {
internal string HandleCommand(string input) {
if (string.IsNullOrEmpty(input)) {
Logging.LogNullError(nameof(input));
return null;