breakpoint
This commit is contained in:
@@ -17,6 +17,7 @@ using BITKit.Net.Examples;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Net
|
||||
{
|
||||
@@ -132,7 +133,7 @@ namespace BITKit.Net
|
||||
{
|
||||
if (IsConnecting)
|
||||
{
|
||||
BIT4Log.Warning<KcpNetClient>("正在连接中");
|
||||
_logger.LogWarning("正在连接中");
|
||||
return false;
|
||||
}
|
||||
_userConnected = true;
|
||||
@@ -203,7 +204,7 @@ namespace BITKit.Net
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogCritical(e,e.Message);
|
||||
if (BITApp.SynchronizationContext is not null)
|
||||
await UniTask.SwitchToSynchronizationContext(BITApp.SynchronizationContext);
|
||||
OnConnectedFailed?.Invoke();
|
||||
@@ -223,7 +224,7 @@ namespace BITKit.Net
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogCritical(e,e.Message);
|
||||
}
|
||||
}
|
||||
private async void OnDataInternel(ArraySegment<byte> bytes, KcpChannel channel)
|
||||
@@ -255,7 +256,7 @@ namespace BITKit.Net
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogCritical(e,e.Message);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -270,7 +271,11 @@ namespace BITKit.Net
|
||||
Ping = (int)(DateTime.Now - _lastPingTime).TotalMilliseconds;
|
||||
break;
|
||||
case NetCommandType.ReturnToClient:
|
||||
|
||||
var id = reader.ReadInt32();
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
if (reader.ReadBoolean())
|
||||
@@ -281,13 +286,14 @@ namespace BITKit.Net
|
||||
else
|
||||
{
|
||||
var message = reader.ReadString();
|
||||
|
||||
_p2p.TryAdd(id,new Exception(message));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.Warning<INetClient>($"请求返回失败:{id}");
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogWarning($"请求返回失败:{id}");
|
||||
_logger.LogCritical(e,e.Message);
|
||||
}
|
||||
break;
|
||||
case NetCommandType.GetFromClient:
|
||||
@@ -327,9 +333,9 @@ namespace BITKit.Net
|
||||
value = methodInfo.Invoke(handle, pars);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
BIT4Log.Warning<KcpNetClient>(path);
|
||||
_logger.LogWarning(path);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -369,7 +375,7 @@ namespace BITKit.Net
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogCritical(e,e.Message);
|
||||
returnWriter.Write(false);
|
||||
returnWriter.Write(e.Message);
|
||||
}
|
||||
@@ -379,7 +385,7 @@ namespace BITKit.Net
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogCritical(e,e.Message);
|
||||
}
|
||||
break;
|
||||
case NetCommandType.AllRpc:
|
||||
@@ -419,13 +425,12 @@ namespace BITKit.Net
|
||||
reportBuilder.AppendLine($"参数{parameter.GetType()}类型匹配:{parameterInfo.ParameterType}");
|
||||
}
|
||||
}
|
||||
|
||||
BIT4Log.Warning<KcpNetClient>(reportBuilder);
|
||||
_logger.LogWarning(reportBuilder.ToString());
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.Warning<KcpNetClient>(rpcName);
|
||||
_logger.LogWarning(rpcName);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -439,6 +444,7 @@ namespace BITKit.Net
|
||||
|
||||
if (eventDelegate is null)
|
||||
{
|
||||
|
||||
//BIT4Log.Warning<KcpNetClient>($"未找到对应的事件:{rpcName}");
|
||||
}
|
||||
else
|
||||
@@ -451,14 +457,13 @@ namespace BITKit.Net
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
BIT4Log.Warning<KcpNetClient>($"未找到对应的Rpc方法:{rpcName}");
|
||||
|
||||
_logger.LogWarning($"未找到对应的Rpc方法:{rpcName}");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_logger.LogInformation($"未知消息类型:{type},字节:{(byte)type}");
|
||||
_logger.LogWarning($"未知消息类型:{type},字节:{(byte)type}");
|
||||
if (bytes.Array != null)
|
||||
_logger.LogInformation(
|
||||
$"已收到:({Id}, {BitConverter.ToString(bytes.Array, bytes.Offset, bytes.Count)} @ {channel})");
|
||||
@@ -694,7 +699,7 @@ namespace BITKit.Net
|
||||
{
|
||||
if (DateTime.Now - _lastHeartbeat > TimeSpan.FromSeconds(5))
|
||||
{
|
||||
BIT4Log.Warning<KcpNetClient>("心跳超时,自动断开");
|
||||
_logger.LogWarning("心跳超时,自动断开");
|
||||
DisconnectInternal();
|
||||
_commandQueue.Clear();
|
||||
return;
|
||||
@@ -726,7 +731,7 @@ namespace BITKit.Net
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.LogException(e);
|
||||
_logger.LogCritical(e,e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user