From 32af9b7bae5c62e1a8aecf71771c7d0dc4a85d3c Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 27 Jul 2017 15:40:57 -0400 Subject: [PATCH] Makes it work --- TGServerService/Interop.cs | 7 ++++--- TGServerService/ServerService.cs | 1 + TGServiceInterface/Server.cs | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/TGServerService/Interop.cs b/TGServerService/Interop.cs index 5f5a04467c..a2786a8af9 100644 --- a/TGServerService/Interop.cs +++ b/TGServerService/Interop.cs @@ -252,16 +252,17 @@ namespace TGServerService } /// - public string InteropMessage(string command) + public bool InteropMessage(string command) { try { HandleCommand(command); - return null; + return true; } catch(Exception e) { - return "Error: " + e.Message; + TGServerService.WriteWarning(String.Format("Handle command for \"{0}\" failed: {1}", command, e.ToString()), TGServerService.EventID.InteropCallException); + return false; } } } diff --git a/TGServerService/ServerService.cs b/TGServerService/ServerService.cs index 7cbc5fb224..e74d43b354 100644 --- a/TGServerService/ServerService.cs +++ b/TGServerService/ServerService.cs @@ -75,6 +75,7 @@ namespace TGServerService ServerUpdateApplied = 6300, ChatBroadcastFail = 6400, IRCLogModes = 6500, + InteropCallException = 6600, } static TGServerService ActiveService; //So everyone else can write to our eventlog diff --git a/TGServiceInterface/Server.cs b/TGServiceInterface/Server.cs index adcff0d50f..c22c6bafac 100644 --- a/TGServiceInterface/Server.cs +++ b/TGServiceInterface/Server.cs @@ -132,9 +132,9 @@ namespace TGServiceInterface /// Called from /world/ExportService(command) /// /// The command to run - /// null on success, error message on failure + /// true on success, false on failure [OperationContract] - string InteropMessage(string command); + bool InteropMessage(string command); } /// @@ -146,17 +146,17 @@ namespace TGServiceInterface /// The proc that DD calls to access /// /// The arguments passed - /// null on success, error message on failure + /// 0 success, -1 on a WCF, error, 1 on an operation error [DllExport("DDEntryPoint", CallingConvention = CallingConvention.Cdecl)] - public static string DDEntryPoint(string[] args) + public static int DDEntryPoint(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 0)]string[] args) { try { - return Server.GetComponent().InteropMessage(String.Join(" ", args)); + return Server.GetComponent().InteropMessage(String.Join(" ", args)) ? 0 : 1; } - catch (Exception e) + catch { - return "Service Error: " + e.Message; + return -1; } } }