2024-10-29 16:28:14 +08:00

41 lines
1.1 KiB
C#

using JiShe.CollectBus.Core.Exceptions;
using Microsoft.Extensions.Logging;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace JiShe.CollectBus.Core.Plugins
{
public partial class TcpClosePlugin(ILogger<TcpClosePlugin> 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 UdpClosePlugin(ILog logger) : PluginBase
{
[GeneratorPlugin(typeof(IUdpReceivedPlugin))]
public Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e)
{
throw new NotImplementedException();
}
}
}