1
This commit is contained in:
@@ -40,6 +40,7 @@ namespace BITKit.Net
|
||||
private readonly ConcurrentDictionary<int,DateTime> _lastHeartbeat = new();
|
||||
|
||||
private readonly ConcurrentQueue<(int id,byte[] bytes)> _sendQueue = new();
|
||||
private readonly ConcurrentDictionary<int,int> _dropCount = new();
|
||||
|
||||
private DateTime _now=DateTime.Now;
|
||||
private TimeSpan _interval=TimeSpan.FromSeconds(0.32);
|
||||
@@ -91,6 +92,7 @@ namespace BITKit.Net
|
||||
|
||||
//BIT4Log.Log<KCPNetServer>($"{Name}目前有{server.connections.Count}个链接");
|
||||
|
||||
_dropCount.Clear();
|
||||
while (_sendQueue.TryDequeue(out var value))
|
||||
{
|
||||
|
||||
@@ -100,9 +102,15 @@ namespace BITKit.Net
|
||||
}
|
||||
else
|
||||
{
|
||||
BIT4Log.Log<KCPNetServer>($"链接{value.id}已丢失,丢弃了{value.bytes.Length}个字节");
|
||||
int UpdateValueFactory(int i, int i1) => i1 + value.bytes.Length;
|
||||
|
||||
_dropCount.AddOrUpdate(value.id,value.bytes.Length,UpdateValueFactory);
|
||||
}
|
||||
}
|
||||
foreach (var (id,length) in _dropCount)
|
||||
{
|
||||
BIT4Log.Log<KCPNetServer>($"未找到链接:{id},已丢弃字节数量:{length}");
|
||||
}
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
@@ -114,6 +122,8 @@ namespace BITKit.Net
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void StartServer(ushort port = 27014)
|
||||
{
|
||||
if (IsRunningServer is false)
|
||||
|
Reference in New Issue
Block a user