From 914936acdcb76e6c92e4173a0351d57bcb46ba38 Mon Sep 17 00:00:00 2001 From: stackia Date: Sat, 30 Jul 2016 12:17:01 +0800 Subject: [PATCH] Revert "Make WCF interface async" This reverts commit fbb24506e25f9b82df33dd21c8c6b74d2d33d1d4. --- ArchiSteamFarm/Program.cs | 2 +- ArchiSteamFarm/WCF.cs | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index f31dbe626..553d75900 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -453,7 +453,7 @@ namespace ArchiSteamFarm { } Logging.LogGenericInfo("Command sent: " + arg); - Logging.LogGenericInfo("Response received: " + WCF.SendCommand(arg).Result); + Logging.LogGenericInfo("Response received: " + WCF.SendCommand(arg)); break; } } diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index f9beec849..8da8ee4ad 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -27,13 +27,12 @@ using System.Linq; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; -using System.Threading.Tasks; namespace ArchiSteamFarm { [ServiceContract] internal interface IWCF { [OperationContract] - Task HandleCommand(string input); + string HandleCommand(string input); } internal sealed class WCF : IWCF, IDisposable { @@ -54,7 +53,7 @@ namespace ArchiSteamFarm { URL = "http://" + Program.GlobalConfig.WCFHostname + ":" + Program.GlobalConfig.WCFPort + "/ASF"; } - public async Task HandleCommand(string input) { + public string HandleCommand(string input) { if (string.IsNullOrEmpty(input)) { Logging.LogNullError(nameof(input)); return null; @@ -70,7 +69,7 @@ namespace ArchiSteamFarm { } string command = "!" + input; - string output = await bot.Response(Program.GlobalConfig.SteamOwnerID, command).ConfigureAwait(false); + string output = bot.Response(Program.GlobalConfig.SteamOwnerID, command).Result; // TODO: This should be asynchronous Logging.LogGenericInfo("Answered to command: " + input + " with: " + output); return output; @@ -125,7 +124,7 @@ namespace ArchiSteamFarm { ServiceHost = null; } - internal async Task SendCommand(string input) { + internal string SendCommand(string input) { if (string.IsNullOrEmpty(input)) { Logging.LogNullError(nameof(input)); return null; @@ -135,21 +134,21 @@ namespace ArchiSteamFarm { Client = new Client(new BasicHttpBinding(), new EndpointAddress(URL)); } - return await Client.HandleCommand(input).ConfigureAwait(false); + return Client.HandleCommand(input); } } - internal sealed class Client : ClientBase { + internal sealed class Client : ClientBase, IWCF { internal Client(Binding binding, EndpointAddress address) : base(binding, address) { } - public async Task HandleCommand(string input) { + public string HandleCommand(string input) { if (string.IsNullOrEmpty(input)) { Logging.LogNullError(nameof(input)); return null; } try { - return await Channel.HandleCommand(input).ConfigureAwait(false); + return Channel.HandleCommand(input); } catch (Exception e) { Logging.LogGenericException(e); return null;