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)
{
if ((_now - startTime).TotalSeconds > 5 || IsConnected is false)
if ((_now - startTime).TotalSeconds > 5)
{
//await BITApp.SwitchToMainThread();
await BITApp.SwitchToMainThread();
if (string.IsNullOrEmpty(path))
{
throw new TimeoutException("请求超时或已断开连接");

View File

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

View File

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

View File

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

View File

@ -135,11 +135,11 @@ TabBar Button:disabled {
.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: initial;
}
#unity-text-input .unity-text-element {
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 {