2024-09-30 17:10:43 +08:00

38 lines
969 B
C#

using JiShe.CollectBus.Core.Exceptions;
using TouchSocket.Core;
using TouchSocket.Sockets;
namespace JiShe.CollectBus.Core.Plugins
{
public class TcpClosePlugin(ILog logger) : PluginBase, ITcpReceivedPlugin
{
public async Task OnTcpReceived(ITcpSession client, ReceivedDataEventArgs e)
{
try
{
await e.InvokeNext();
}
catch (CloseException ex)
{
logger.Info("拦截到CloseException");
client.Close(ex.Message);
}
catch (Exception exx)
{
// ignored
}
finally
{
}
}
}
public class UdpClosePlugin(ILog logger) : PluginBase, IUdpReceivedPlugin
{
public async Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e)
{
throw new NotImplementedException();
}
}
}