using JiShe.CollectBus.Network.Exceptions; using Microsoft.Extensions.Logging; using TouchSocket.Core; using TouchSocket.Sockets; namespace JiShe.CollectBus.Network.Plugins { public partial class TcpCloseMonitor(ILogger logger) : PluginBase { [GeneratorPlugin(typeof(ITcpReceivedPlugin))] public async Task OnTcpReceived(ITcpSessionClient client, ReceivedDataEventArgs e) { try { await e.InvokeNext(); } catch (CloseException ex) { logger.LogInformation("拦截到CloseException"); client.Close(ex.Message); } catch (Exception exx) { // ignored } finally { } } } public partial class UdpCloseMonitor(ILogger logger) : PluginBase { [GeneratorPlugin(typeof(IUdpReceivedPlugin))] public Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e) { throw new NotImplementedException(); } } }