using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Sockets;

namespace JiShe.CollectBus.Plugins
{
    public partial class UdpMonitor : PluginBase, IUdpReceivedPlugin
    {
        public async Task OnUdpReceived(IUdpSessionBase client, UdpReceivedDataEventArgs e)
        {
            var udpSession = client as UdpSession;
            udpSession?.Logger.Info($"[UDP] 收到：{e.ByteBlock.Span.ToString(Encoding.UTF8)}");
            await udpSession.SendAsync("[UDP] 收到");

            await e.InvokeNext();
        }
    }
}
