2024-09-30 17:10:43 +08:00
|
|
|
|
using JiShe.CollectBus.Core.Exceptions;
|
2024-10-29 16:28:14 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-09-30 17:10:43 +08:00
|
|
|
|
using TouchSocket.Core;
|
|
|
|
|
|
using TouchSocket.Sockets;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Core.Plugins
|
|
|
|
|
|
{
|
2024-10-29 16:28:14 +08:00
|
|
|
|
public partial class TcpClosePlugin(ILogger<TcpClosePlugin> logger) : PluginBase
|
2024-09-30 17:10:43 +08:00
|
|
|
|
{
|
2024-10-22 20:57:26 +08:00
|
|
|
|
[GeneratorPlugin(typeof(ITcpReceivedPlugin))]
|
|
|
|
|
|
public async Task OnTcpReceived(ITcpSessionClient client, ReceivedDataEventArgs e)
|
2024-09-30 17:10:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
await e.InvokeNext();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (CloseException ex)
|
|
|
|
|
|
{
|
2024-10-29 16:28:14 +08:00
|
|
|
|
logger.LogInformation("拦截到CloseException");
|
2024-09-30 17:10:43 +08:00
|
|
|
|
client.Close(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exx)
|
|
|
|
|
|
{
|
|
|
|
|
|
// ignored
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-22 20:57:26 +08:00
|
|
|
|
public partial class UdpClosePlugin(ILog logger) : PluginBase
|
2024-09-30 17:10:43 +08:00
|
|
|
|
{
|
2024-10-22 20:57:26 +08:00
|
|
|
|
[GeneratorPlugin(typeof(IUdpReceivedPlugin))]
|
2024-10-11 11:27:57 +08:00
|
|
|
|
public Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e)
|
2024-09-30 17:10:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|