This commit is contained in:
CortexCore
2024-08-05 09:53:22 +08:00
parent d33e1c1713
commit cc3d6f0ef1
7 changed files with 52 additions and 13 deletions

View File

@@ -118,6 +118,12 @@ namespace BITKit.Net
public async UniTask<bool> Connect(string address = "127.0.0.1", ushort port = 27014)
{
if (IsConnecting)
{
BIT4Log.Warning<KcpNetClient>("正在连接中");
return false;
}
//如果address是域名,解析为Ip
if (address.Contains("."))
{
@@ -128,13 +134,13 @@ namespace BITKit.Net
BIT4Log.Log<KcpNetClient>($"解析域名:{address}");
}
}
if (address is not "127.0.0.1")
_connectedAddress = address;
if (port is not 27014)
_connectedPort = port;
if (IsConnecting)
{
BIT4Log.Warning<KcpNetClient>("正在连接中");
return false;
}
IsConnecting = true;
if (client.connected) return false;
await BITApp.SwitchToMainThread();

View File

@@ -325,7 +325,12 @@ namespace BITKit.Net
{
dynamic result = methodInfo.Invoke(handle, pars)!;
if (methodInfo.ReturnType == typeof(void) || methodInfo.ReturnType == typeof(UniTask))
if (methodInfo.ReturnType == typeof(void)
||
methodInfo.ReturnType == typeof(UniTask)
||
methodInfo.ReturnType == typeof(UniTask<>)
)
{
await result;
value = -1;