mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-29 16:11:05 +01:00
53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using RGiesecke.DllExport;
|
|
using System.Runtime.InteropServices;
|
|
using System.ServiceModel;
|
|
|
|
namespace TGServiceInterface
|
|
{
|
|
|
|
/// <summary>
|
|
/// Used by DD to access the interop API with call()()
|
|
/// </summary>
|
|
[ServiceContract]
|
|
public interface ITGInterop
|
|
{
|
|
/// <summary>
|
|
/// Called from /world/ExportService(command)
|
|
/// </summary>
|
|
/// <param name="command">The command to run</param>
|
|
/// <returns>true on success, false on failure</returns>
|
|
[OperationContract]
|
|
bool InteropMessage(string command);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Holds the proc that DD calls to access <see cref="ITGServiceBridge"/>
|
|
/// </summary>
|
|
public class DDInteropCallHolder
|
|
{
|
|
/// <summary>
|
|
/// The proc that DD calls to access <see cref="ITGServiceBridge"/>
|
|
/// </summary>
|
|
/// <param name="args">The arguments passed</param>
|
|
/// <returns>0</returns>
|
|
[DllExport("DDEntryPoint", CallingConvention = CallingConvention.Cdecl)]
|
|
public static int DDEntryPoint(int argc, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 0)]string[] args)
|
|
{
|
|
try
|
|
{
|
|
var channel = Server.CreateChannel<ITGInterop>();
|
|
try
|
|
{
|
|
channel.CreateChannel().InteropMessage(String.Join(" ", args));
|
|
}
|
|
catch { }
|
|
Server.CloseChannel(channel);
|
|
|
|
}
|
|
catch { }
|
|
return 0;
|
|
}
|
|
}
|
|
}
|