This commit is contained in:
parent
18d888dfce
commit
d044175e77
|
@ -137,7 +137,7 @@ namespace BITKit
|
|||
}
|
||||
public static void Write(BinaryWriter writer, object value)
|
||||
{
|
||||
if (value is IEnumerable enumerable and not string)
|
||||
if (value is not string && value is IList enumerable)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -26,12 +26,13 @@ namespace BITKit.Net
|
|||
public event Action OnConnectedFailed;
|
||||
public bool IsConnected => _isConnected;
|
||||
public bool IsConnecting { get; private set; }
|
||||
public double RpcTimeOut { get; set; } = 5;
|
||||
public bool AutoReconnect { get; set; } = true;
|
||||
public float2 Traffic { get; set; }
|
||||
public bool ManualTick { get; set; }
|
||||
|
||||
private readonly IntervalUpdate _reconnectInterval = new(1);
|
||||
|
||||
|
||||
public int Ping { get; private set; }
|
||||
public int Id { get; private set; } = -1;
|
||||
private readonly KcpClient client;
|
||||
|
@ -199,7 +200,7 @@ namespace BITKit.Net
|
|||
switch (type)
|
||||
{
|
||||
case NetCommandType.Message:
|
||||
BIT4Log.Log<KcpClient>($"已收到消息:{reader.ReadString()}");
|
||||
BIT4Log.Log<KcpNetClient>($"已收到消息:{reader.ReadString()}");
|
||||
break;
|
||||
case NetCommandType.AllClientCommand:
|
||||
case NetCommandType.Command:
|
||||
|
@ -386,14 +387,14 @@ namespace BITKit.Net
|
|||
{
|
||||
|
||||
|
||||
BIT4Log.Warning<KcpClient>($"未找到对应的Rpc方法:{rpcName}");
|
||||
BIT4Log.Warning<KcpNetClient>($"未找到对应的Rpc方法:{rpcName}");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BIT4Log.Log<KcpClient>($"未知消息类型:{type},字节:{(byte)type}");
|
||||
BIT4Log.Log<KcpNetClient>($"未知消息类型:{type},字节:{(byte)type}");
|
||||
if (bytes.Array != null)
|
||||
BIT4Log.Log<KcpClient>(
|
||||
BIT4Log.Log<KcpNetClient>(
|
||||
$"已收到:({Id}, {BitConverter.ToString(bytes.Array, bytes.Offset, bytes.Count)} @ {channel})");
|
||||
break;
|
||||
}
|
||||
|
@ -414,7 +415,7 @@ namespace BITKit.Net
|
|||
}
|
||||
private void OnError(ErrorCode errorCode, string message)
|
||||
{
|
||||
BIT4Log.Log<KCPNetServer>($"{client.remoteEndPoint}异常:{errorCode},{message}");
|
||||
BIT4Log.Log<KcpNetClient>($"{client.remoteEndPoint}异常:{errorCode},{message}");
|
||||
}
|
||||
|
||||
public void ServerCommand<T>(T command = default)
|
||||
|
@ -476,7 +477,7 @@ namespace BITKit.Net
|
|||
|
||||
while (true)
|
||||
{
|
||||
if ((_now - startTime).TotalSeconds > 5)
|
||||
if ((_now - startTime).TotalSeconds > RpcTimeOut)
|
||||
{
|
||||
await BITApp.SwitchToMainThread();
|
||||
if (string.IsNullOrEmpty(path))
|
||||
|
@ -505,6 +506,8 @@ namespace BITKit.Net
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UniTask<T> GetFromClient<T>(int id,string path, params object[] pars)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
@ -357,7 +357,18 @@ namespace BITKit.Net
|
|||
returnWriter.Write(true);
|
||||
if (value is not null)
|
||||
{
|
||||
BITBinary.Write(returnWriter, value);
|
||||
try
|
||||
{
|
||||
BITBinary.Write(returnWriter, value);
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue