static Tuple <AutomationRequestResult, byte[]> SendRequest(AutomationRequestType Request, byte[] RequestData) { int PortNumber = (int)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Epic Games\\UnrealGameSync", "AutomationPort", null); using (TcpClient Client = new TcpClient()) { Client.Connect(new IPEndPoint(IPAddress.Loopback, PortNumber)); using (NetworkStream Stream = Client.GetStream()) { // Send the request BinaryWriter Writer = new BinaryWriter(Stream); Writer.Write((int)Request); Writer.Write(RequestData.Length); Writer.Write(RequestData); // Read the response BinaryReader Reader = new BinaryReader(Stream); AutomationRequestResult Result = (AutomationRequestResult)Reader.ReadInt32(); int ResponseLength = Reader.ReadInt32(); byte[] ResponseData = Reader.ReadBytes(ResponseLength); // Return the response return(Tuple.Create(Result, ResponseData)); } } }
public AutomationRequestInput(AutomationRequestType Type, byte[] Data) { this.Type = Type; this.Data = Data; }