Skip to content

Commit a000146

Browse files
committed
ASF 3 compatibility
1 parent c83ee53 commit a000146

File tree

2 files changed

+47
-36
lines changed

2 files changed

+47
-36
lines changed

ASFui/ASFProcess.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,25 @@ public ASFProcess(ASFui asf, RichTextBox rtb)
2929
}
3030

3131
private void init() {
32-
var ASFInfo = new ProcessStartInfo() {
33-
Arguments = "--server",
34-
CreateNoWindow = true,
35-
Domain = "",
36-
FileName = Properties.Settings.Default.ASFBinary,
37-
LoadUserProfile = false,
38-
Password = null,
39-
RedirectStandardError = true,
40-
RedirectStandardInput = true,
41-
RedirectStandardOutput = true,
42-
StandardErrorEncoding = Encoding.UTF8,
43-
StandardOutputEncoding = Encoding.UTF8,
44-
UseShellExecute = false,
45-
WindowStyle = ProcessWindowStyle.Hidden
46-
};
32+
var ASFInfo = new ProcessStartInfo() {
33+
Arguments = "--server",
34+
CreateNoWindow = true,
35+
Domain = "",
36+
FileName = Properties.Settings.Default.ASFBinary,
37+
LoadUserProfile = false,
38+
Password = null,
39+
RedirectStandardError = true,
40+
RedirectStandardInput = true,
41+
RedirectStandardOutput = true,
42+
StandardErrorEncoding = Encoding.UTF8,
43+
StandardOutputEncoding = Encoding.UTF8,
44+
UseShellExecute = false,
45+
WindowStyle = ProcessWindowStyle.Hidden
46+
};
47+
if (Properties.Settings.Default.ASFBinary.EndsWith("dll")) {
48+
ASFInfo.Arguments = Properties.Settings.Default.ASFBinary + " --server";
49+
ASFInfo.FileName = "dotnet";
50+
}
4751

4852
ASF.StartInfo = ASFInfo;
4953
ASF.OutputDataReceived += OutputHandler;

ASFui/Util.cs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace ASFui
1313
{
1414
internal static class Util
1515
{
16-
private static readonly NetTcpBinding Binding = new NetTcpBinding { SendTimeout = new TimeSpan(0, 30, 0), Security = { Mode = SecurityMode.None } };
16+
private static readonly NetTcpBinding Binding = new NetTcpBinding { SendTimeout = new TimeSpan(0, 30, 0), Security = { Mode = SecurityMode.None } };
1717

1818
public static bool CheckBinary()
1919
{
@@ -22,11 +22,17 @@ public static bool CheckBinary()
2222

2323
public static string SendCommand(string command)
2424
{
25-
using (var asfClient = new Client(Binding, new EndpointAddress(GetEndpointAddress())))
26-
{
27-
return asfClient.HandleCommand(command);
28-
}
29-
}
25+
string adress;
26+
if ((adress = GetEndpointAddress()).StartsWith("net")){
27+
using (var asfClient = new Client(Binding, new EndpointAddress(adress))) {
28+
return asfClient.HandleCommand(command);
29+
}
30+
}
31+
32+
using (WebClient webclient = new WebClient()) {
33+
return webclient.DownloadString(adress +"?command="+command);
34+
}
35+
}
3036

3137
public static string GenerateCommand(string command, string user, string args = "")
3238
{
@@ -49,21 +55,22 @@ public static string GetEndpointAddress()
4955
JObject.Parse(
5056
File.ReadAllText(Path.GetDirectoryName(Settings.Default.ASFBinary) + @"/config/ASF.json"));
5157

52-
var hostname= "127.0.0.1";
53-
var port = "1242";
54-
try
55-
{
56-
hostname = json["WCFHost"].ToString();
57-
}
58-
catch
59-
{
60-
try {
61-
hostname = json["WCFHostname"].ToString();
62-
} catch { /* Ignore */ }
63-
}
64-
try {
65-
port = json["WCFPort"].ToString();
66-
} catch { /* Ignore */ }
58+
var hostname = "127.0.0.1";
59+
var port = "1242";
60+
//newversion:
61+
if (null==json["WCFHost"] && json["WCFPort"]==null && json["WCFHostname"] == null) {
62+
if (null != json["IPCHostname"])
63+
hostname = json["IPCHostname"].ToString();
64+
if (null != json["IPCPort"])
65+
port = json["IPCPort"].ToString();
66+
return "http://" + hostname + ":" + port + "/IPC";
67+
}
68+
if (null != json["WCFHost"])
69+
hostname = json["WCFHost"].ToString();
70+
if (null != json["WCFHostname"])
71+
hostname = json["WCFHostname"].ToString();
72+
if (null != json["WCFPort"])
73+
port = json["WCFPort"].ToString();
6774

6875
return "net.tcp://" + hostname + ":" + port + "/ASF";
6976
}

0 commit comments

Comments
 (0)