This commit is contained in:
CortexCore
2024-07-27 14:55:18 +08:00
parent ed4ef12f22
commit 0cd23abbc5
5 changed files with 25 additions and 16 deletions

View File

@@ -463,9 +463,9 @@ namespace BITKit.Net
while (true) while (true)
{ {
if ((_now - startTime).TotalSeconds > 5 || IsConnected is false) if ((_now - startTime).TotalSeconds > 5)
{ {
//await BITApp.SwitchToMainThread(); await BITApp.SwitchToMainThread();
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
{ {
throw new TimeoutException("请求超时或已断开连接"); throw new TimeoutException("请求超时或已断开连接");

View File

@@ -80,7 +80,7 @@ namespace BITKit.Net
{ {
server.Send(id,_heartBeat , KcpChannel.Unreliable); server.Send(id,_heartBeat , KcpChannel.Unreliable);
if (!_lastHeartbeat.TryGetValue(id, out var time)) continue; if (!_lastHeartbeat.TryGetValue(id, out var time)) continue;
if (!((_now - time).TotalSeconds > 1)) continue; if (!((_now - time).TotalSeconds > 3)) continue;
server.Disconnect(id); server.Disconnect(id);
_lastHeartbeat.TryRemove(id); _lastHeartbeat.TryRemove(id);
BIT4Log.Log<KCPNetServer>($"{Name}:链接{id}超时,已断开"); BIT4Log.Log<KCPNetServer>($"{Name}:链接{id}超时,已断开");

View File

@@ -270,7 +270,6 @@ namespace BITKit.Console
keyDownEvent.PreventDefault(); keyDownEvent.PreventDefault();
} }
} }
private void Toggle(InputAction.CallbackContext context) private void Toggle(InputAction.CallbackContext context)
{ {
switch (context) switch (context)

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using BITKit.Net.Examples; using BITKit.Net.Examples;
@@ -253,27 +254,36 @@ namespace BITKit.Net.Kcp
private async void Hello() private async void Hello()
{ {
BITAppForUnity.ThrowIfNotPlaying(); BITAppForUnity.ThrowIfNotPlaying();
var stopWatch = new Stopwatch();
stopWatch.Start();
var value =await GetFromServer<SimplePing>(null,new SimplePing() var value =await GetFromServer<SimplePing>(null,new SimplePing()
{ {
StartTime = DateTime.Now StartTime = DateTime.Now
}); });
BIT4Log.Log<MonoKcpClient>($"已返回\n开始:{value.StartTime}\n结束:{value.EndTime}\n延迟:{(value.EndTime-value.StartTime).TotalMilliseconds}ms"); stopWatch.Stop();
BIT4Log.Log<MonoKcpClient>($"已返回\n开始:{value.StartTime}\n结束:{value.EndTime}\n延迟:{stopWatch.ElapsedMilliseconds}ms");
stopWatch.Reset();
stopWatch.Start();
var hello = var hello =
await GetFromServer<string>( await GetFromServer<string>(
nameof(KCPNetServer.MyRpcTest), nameof(KCPNetServer.MyRpcTest),
"hello" "hello"
); );
BIT4Log.Log<MonoKcpClient>($"延迟:{(DateTime.Now-value.StartTime).TotalMilliseconds}ms"); stopWatch.Stop();
BIT4Log.Log<MonoKcpClient>($"已返回\n{hello}\n延迟:{stopWatch.ElapsedMilliseconds}ms");
BIT4Log.Log<MonoKcpClient>($"已返回\n{hello}"); stopWatch.Reset();
var helloAsync = stopWatch.Start();
await GetFromServer<string>( var helloAsync =
nameof(KCPNetServer.MyRpcTestAsync), await GetFromServer<string>(
"hello" nameof(KCPNetServer.MyRpcTestAsync),
); "hello"
);
stopWatch.Stop();
BIT4Log.Log<MonoKcpClient>($"已返回\n{helloAsync},\n延迟:{stopWatch.ElapsedMilliseconds}ms");
BIT4Log.Log<MonoKcpClient>($"已返回\n{helloAsync}");
} }
} }
} }

View File

@@ -135,11 +135,11 @@ TabBar Button:disabled {
.unity-text-element { .unity-text-element {
-unity-font-definition: url("project://database/Assets/BITKit/Unity/Art/Fonts/SDF/Roboto-Regular%20SDF.asset?fileID=11400000&guid=5b449e7b33d231a4085b869a8ae2c94c&type=2#Roboto-Regular SDF"); -unity-font-definition: url("project://database/Assets/BITKit/Unity/Art/Fonts/SDF/Roboto-Regular%20SDF.asset?fileID=11400000&guid=5b449e7b33d231a4085b869a8ae2c94c&type=2#Roboto-Regular SDF");
-unity-font: initial;
} }
#unity-text-input .unity-text-element { #unity-text-input .unity-text-element {
color: rgb(32, 32, 32); color: rgb(32, 32, 32);
-unity-font-definition: url("project://database/Assets/BITKit/Unity/Art/Fonts/SDF/SourceHanMono-Regular%20SDF.asset?fileID=11400000&guid=2f61e01f10d33fb48a56bb976a364395&type=2#SourceHanMono-Regular SDF");
} }
.theme-light .unity-text-element { .theme-light .unity-text-element {