From 594a0f141013c8e6fccbe394f23eeeff2e246754 Mon Sep 17 00:00:00 2001 From: Kimdiego2098 <2248356998@qq.com> Date: Fri, 27 Oct 2023 14:24:26 +0800 Subject: [PATCH] update the tcpserver class and add log output for start and stop --- .../Components/DebugPage/TcpServerPage.razor | 4 ++-- .../BaseReadWrite/ReadWriteDevicesTcpServerBase.cs | 3 ++- .../TouchSocket/Socket/Components/Tcp/TcpService.cs | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/framework/Demo/ThingsGateway.Foundation.Demo.Rcl/Components/DebugPage/TcpServerPage.razor b/framework/Demo/ThingsGateway.Foundation.Demo.Rcl/Components/DebugPage/TcpServerPage.razor index 1c73f884d..3f420a089 100644 --- a/framework/Demo/ThingsGateway.Foundation.Demo.Rcl/Components/DebugPage/TcpServerPage.razor +++ b/framework/Demo/ThingsGateway.Foundation.Demo.Rcl/Components/DebugPage/TcpServerPage.razor @@ -26,10 +26,10 @@ - 连接 + 启动 - 断开 + 停止 diff --git a/framework/Foundation/ThingsGateway.Foundation/Foundation/BaseReadWrite/ReadWriteDevicesTcpServerBase.cs b/framework/Foundation/ThingsGateway.Foundation/Foundation/BaseReadWrite/ReadWriteDevicesTcpServerBase.cs index 5647c85e7..5d5a5b5e4 100644 --- a/framework/Foundation/ThingsGateway.Foundation/Foundation/BaseReadWrite/ReadWriteDevicesTcpServerBase.cs +++ b/framework/Foundation/ThingsGateway.Foundation/Foundation/BaseReadWrite/ReadWriteDevicesTcpServerBase.cs @@ -55,7 +55,8 @@ public abstract class ReadWriteDevicesTcpServerBase : ReadWriteDevicesBase /// public override Task ConnectAsync(CancellationToken cancellationToken) { - return Task.Run(() => TcpService.Start()); + Connect(cancellationToken); + return EasyTask.CompletedTask; } /// diff --git a/framework/Foundation/ThingsGateway.Foundation/TouchSocket/Socket/Components/Tcp/TcpService.cs b/framework/Foundation/ThingsGateway.Foundation/TouchSocket/Socket/Components/Tcp/TcpService.cs index ecf87f04c..ee1e8ea0e 100644 --- a/framework/Foundation/ThingsGateway.Foundation/TouchSocket/Socket/Components/Tcp/TcpService.cs +++ b/framework/Foundation/ThingsGateway.Foundation/TouchSocket/Socket/Components/Tcp/TcpService.cs @@ -493,6 +493,11 @@ namespace ThingsGateway.Foundation.Sockets /// public override IService Stop() { + foreach (var item in m_monitors) + { + Logger.Info($"{item.Option.IpHost}停止成功"); + } + foreach (var item in this.m_monitors) { item.Socket.SafeDispose(); @@ -603,6 +608,7 @@ namespace ThingsGateway.Foundation.Sockets foreach (var item in optionList) { this.AddListen(item); + Logger.Info($"{item.IpHost}启动成功"); } }