make it sortof work

This commit is contained in:
Chris Forbes
2011-01-04 20:52:26 +13:00
parent f44ac769bf
commit f03e6e6258
4 changed files with 26 additions and 10 deletions

View File

@@ -108,7 +108,7 @@ namespace OpenRA.Launcher
string url = args[0];
string dest = args[1];
string pipename = UtilityProgram.GetPipeName();
var p = UtilityProgram.Call("--download-url", pipename, url, dest);
var p = UtilityProgram.Call("--download-url", pipename, null, url, dest);
Regex r = new Regex(@"(\d{1,3})% (\d+)/(\d+) bytes");
NamedPipeClientStream pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);

View File

@@ -169,13 +169,22 @@ namespace OpenRA.Launcher
public void httpRequest(string url, string callbackName)
{
string pipename = UtilityProgram.GetPipeName();
var p = UtilityProgram.Call("--download-url", pipename, url);
var pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);
p.Exited += (_, e) =>
var p = UtilityProgram.Call("--download-url", pipename,
(_, e) =>
{
using (var reader = new StreamReader(pipe))
document.InvokeScript(callbackName, new object[] { reader.ReadToEnd() });
};
{
var data = reader.ReadToEnd();
/* debug */
MessageBox.Show(
string.Format("Finished HTTP Request -- {0},{1} => {2}",
url, callbackName, data));
document.InvokeScript(callbackName, new object[] { data });
}
}, url);
pipe.Connect();
}

View File

@@ -71,13 +71,19 @@ namespace OpenRA.Launcher
return arguments.ToString();
}
public static Process Call(string command, string pipename, params string[] args)
public static Process Call(string command, string pipename, EventHandler onExit, params string[] args)
{
Process p = new Process();
p.StartInfo.FileName = "OpenRA.Utility.exe";
p.StartInfo.Arguments = BuildArgs(command, args) + " --pipe=" + pipename;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
if (onExit != null)
{
p.EnableRaisingEvents = true;
p.Exited += onExit;
}
p.Start();
@@ -87,7 +93,7 @@ namespace OpenRA.Launcher
public static string CallSimpleResponse(string command, params string[] args)
{
string pipename = GetPipeName();
Call(command, pipename, args);
Call(command, pipename, null, args);
string responseString;
NamedPipeClientStream pipe = new NamedPipeClientStream(".", pipename, PipeDirection.In);
pipe.Connect();