fix bug: couldn't convert package

This commit is contained in:
2025-04-17 14:25:37 +08:00
parent 3b674f413a
commit d25f9882fc
7 changed files with 187 additions and 45 deletions

View File

@@ -2,6 +2,7 @@ using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using DotNext;
using DotNext.Threading;
using Newtonsoft.Json;
@@ -392,6 +393,23 @@ public class UDPServer
}
}
/// <summary>
/// 清空指定IP地址的数据
/// </summary>
/// <param name="ipAddr">IP地址</param>
/// <returns>无</returns>
public async Task ClearUDPData(string ipAddr)
{
using (await udpData.AcquireWriteLockAsync())
{
if (udpData.TryGetValue(ipAddr, out var dataQueue) && dataQueue.Count > 0)
{
dataQueue.Clear();
}
}
}
/// <summary>
/// Start UDP Server
/// </summary>