tcp连接逻辑

添加登录动画
This commit is contained in:
sc committed 2026-05-03 22:11:28 +08:00
commit 9abaeaf43b
6 files changed
+209 -7

No files matched your search

+17 -3
View File
@@ -21,6 +21,10 @@ namespace SunlightAggregationTerminal.Class
ServerName = Name;
ServerPassword = Password;
ServerTerminal = Terminal;
_= TcpClient(tcpClient, ServerIP, "7789");
}
public static async void Query(string Dat)
{
@@ -30,10 +34,8 @@ namespace SunlightAggregationTerminal.Class
}
private static async Task CreateCustomService()
public static async Task TcpClient(TcpClient tcpClient, string ip, string port)
{
tcpClient.Config.SetRemoteIPHost(ServerIP);
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
tcpClient.Connected = (client, e) => { return EasyTask.CompletedTask; };//成功连接到服务器
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
@@ -44,10 +46,22 @@ namespace SunlightAggregationTerminal.Class
//从服务器收到信息。但是一般byteBlock和requestInfo会根据适配器呈现不同的值。
var mes = e.Memory.Span.ToString(Encoding.UTF8);
tcpClient.Logger.Info($"客户端接收到信息:{mes}");
return EasyTask.CompletedTask;
};
#endregion
await tcpClient.SetupAsync(new TouchSocketConfig()
.SetRemoteIPHost(ip + ":" + port)
.ConfigurePlugins(a =>
{
})
.ConfigureContainer(a =>
{
}
));
await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
}
}