diff --git a/UserClass/AsyncTcpClient.cs b/UserClass/AsyncTcpClient.cs index 384afb4..5a9326e 100644 --- a/UserClass/AsyncTcpClient.cs +++ b/UserClass/AsyncTcpClient.cs @@ -103,21 +103,17 @@ namespace SunlightAggregationManager.UserClass MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict); Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]"); - CommandC(deserializedPerson?.Dat ?? "NOT", deserializedPerson!); - + CommandC(deserializedPerson?.Dat ?? "NOT", deserializedPerson!); } else {//停用账号关闭连接 - client.SendAsync("Account Deactivated"); - + client.SendAsync("Account Deactivated"); } } else { //无效账号关闭连接 - client.SendAsync("Invalid Account"); - + client.SendAsync("Invalid Account"); } - } catch (Exception ex) {//错误 @@ -134,12 +130,22 @@ namespace SunlightAggregationManager.UserClass await tcpClient.SetupAsync(new TouchSocketConfig() .SetSingleStreamDataHandlingAdapter(() => new PeriodPackageAdapter())//以超时周期和包 .SetRemoteIPHost(ip) + .SetKeepAliveValue(options => //心跳 + { + options.AckInterval = 2000; + options.Interval = 30 * 1000; + }) .ConfigurePlugins(a => { a.UseReconnection(options => { options.PollingInterval = TimeSpan.FromSeconds(3); }); + + }) + .ConfigureContainer(a => + { + })); await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。 diff --git a/View/imgQR.xaml.cs b/View/imgQR.xaml.cs index dc3fdab..e366860 100644 --- a/View/imgQR.xaml.cs +++ b/View/imgQR.xaml.cs @@ -99,7 +99,7 @@ namespace SunlightAggregationManager.View { string text_APP = "TEST"; // string text_LINK = MainWindowViewModel.MachineIP + ":"+ MainWindowViewModel.MachineIPP1 + - ",HTTP//:" + MainWindowViewModel.SERVERIP + "/" + MainWindowViewModel.Enterprise; + "," + MainWindowViewModel.SERVERIP + "/"+ MainWindowViewModel.Enterprise; // 要生成二维码的内容 imgQR_CREATE(text_APP, imgQR_app); diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 6df0451..dc473b9 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -31,6 +31,7 @@ namespace SunlightAggregationManager.ViewModel public static string MachineIP = ""; public static int MachineIPP1 = 7789; public static int MachineIPP2 = 7790; + public static int MachineHTTPP = 7791; public static string Enterprise = ""; public static string TCP_E = "0"; public static string HTTP_E = "0"; @@ -127,15 +128,14 @@ namespace SunlightAggregationManager.ViewModel } if (HTTP_E == "1")//启动tcp(内网直连) { - int P1; try { - P1 = int.Parse(Configini.IniReadvalue("NETWORK", "HTTP_PORT")); + MachineHTTPP = int.Parse(Configini.IniReadvalue("NETWORK", "HTTP_PORT")); } - catch (Exception) { P1 = 7791; } + catch (Exception) { MachineHTTPP = 7791; } Service.Rows.Add(2, "RUN", "HTTP"); - AsyncHttpServer.Configuration(P1); + AsyncHttpServer.Configuration(MachineHTTPP); } else {