2024-10-22 20:57:26 +08:00

40 lines
1.0 KiB
C#

using JiShe.CollectBus.Core.Exceptions;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace JiShe.CollectBus.Core.Plugins
{
public partial class TcpClosePlugin(ILog logger) : PluginBase
{
[GeneratorPlugin(typeof(ITcpReceivedPlugin))]
public async Task OnTcpReceived(ITcpSessionClient client, ReceivedDataEventArgs e)
{
try
{
await e.InvokeNext();
}
catch (CloseException ex)
{
logger.Info("拦截到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();
}
}
}