breakpoint
This commit is contained in:
parent
01b3d1be43
commit
000a079985
|
@ -176,12 +176,7 @@ namespace BITKit
|
|||
/// <summary>
|
||||
/// 依赖服务提供接口
|
||||
/// </summary>
|
||||
public static ServiceProvider ServiceProvider
|
||||
{
|
||||
get=>_serviceProvider??=ServiceCollection.BuildServiceProvider();
|
||||
set => _serviceProvider = value;
|
||||
}
|
||||
private static ServiceProvider _serviceProvider;
|
||||
public static ServiceProvider ServiceProvider { get; set; }
|
||||
/// <summary>
|
||||
/// 主线程
|
||||
/// </summary>
|
||||
|
|
|
@ -8,70 +8,92 @@ using UnityEngine;
|
|||
|
||||
namespace BITKit
|
||||
{
|
||||
public static class BIT4Log
|
||||
{
|
||||
#if UNITY_EDITOR && UNITY_5_3_OR_NEWER
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void Reload()
|
||||
public static class BIT4Log
|
||||
{
|
||||
OnLog = null;
|
||||
OnException = null;
|
||||
OnWarning = null;
|
||||
OnNextLine = null;
|
||||
}
|
||||
#endif
|
||||
public static event Action<string> OnLog;
|
||||
public static event Action<Exception> OnException;
|
||||
public static event Action<string> OnWarning;
|
||||
public static event Action OnNextLine;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
#if UNITY_EDITOR && UNITY_5_3_OR_NEWER
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void Reload()
|
||||
{
|
||||
OnLog = null;
|
||||
OnException = null;
|
||||
OnWarning = null;
|
||||
OnNextLine = null;
|
||||
}
|
||||
#endif
|
||||
public static void Log(object x)
|
||||
{
|
||||
if (OnLog is null)
|
||||
{
|
||||
BITApp.ServiceProvider.GetRequiredService<ILogger<BITApp>>().LogInformation(x.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
OnLog?.Invoke(x?.ToString());
|
||||
}
|
||||
}
|
||||
public static event Action<string> OnLog;
|
||||
public static event Action<Exception> OnException;
|
||||
public static event Action<string> OnWarning;
|
||||
public static event Action OnNextLine;
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
[HideInCallstack]
|
||||
#endif
|
||||
public static void Log<T>(object x)
|
||||
{
|
||||
if (OnLog is null)
|
||||
{
|
||||
BITApp.ServiceProvider.GetRequiredService<ILogger<T>>().LogInformation(x.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
OnLog?.Invoke(x?.ToString());
|
||||
}
|
||||
}
|
||||
public static void Log(object x)
|
||||
{
|
||||
if (OnLog is not null)
|
||||
{
|
||||
OnLog.Invoke(x?.ToString());
|
||||
return;
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
UnityEngine.Debug.Log(x);
|
||||
#endif
|
||||
public static void LogException(Exception e)
|
||||
{
|
||||
OnException?.Invoke(e);
|
||||
}
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
[HideInCallstack]
|
||||
#endif
|
||||
public static void Warning(object x)
|
||||
{
|
||||
OnWarning?.Invoke(x.ToString());
|
||||
}
|
||||
public static void Log<T>(object x)
|
||||
{
|
||||
if (OnLog is not null)
|
||||
{
|
||||
OnLog.Invoke(x?.ToString());
|
||||
return;
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
UnityEngine.Debug.Log($"<b>{typeof(T).Name}</b>" + x);
|
||||
#endif
|
||||
public static void Warning<T>(object x)
|
||||
{
|
||||
Warning($"<color=#ffa500ff><b>{typeof(T).Name}</b></color>:{x}");
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
#endif
|
||||
public static void LogException(Exception e)
|
||||
{
|
||||
if (OnException is not null)
|
||||
{
|
||||
OnException.Invoke(e);
|
||||
return;
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
UnityEngine.Debug.LogException(e);
|
||||
#endif
|
||||
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
#endif
|
||||
public static void Warning(object x)
|
||||
{
|
||||
if (OnWarning is not null)
|
||||
{
|
||||
OnWarning.Invoke(x.ToString());
|
||||
return;
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
UnityEngine.Debug.LogWarning(x);
|
||||
#endif
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
[HideInCallstack]
|
||||
#endif
|
||||
public static void Warning<T>(object x)
|
||||
{
|
||||
if (OnWarning is not null)
|
||||
{
|
||||
OnWarning.Invoke(x.ToString());
|
||||
return;
|
||||
}
|
||||
#if UNITY_5_3_OR_NEWER
|
||||
UnityEngine.Debug.LogWarning($"<b>{typeof(T).Name}</b>" + x);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -66,12 +66,6 @@ namespace BITKit
|
|||
{
|
||||
var outputPath = PathHelper.GetTempFilePath();
|
||||
|
||||
//DI.TryGet<IUXWaiting>(out var waiting);
|
||||
//todo
|
||||
IUXWaiting waiting = null;
|
||||
|
||||
var handle = waiting?.Get();
|
||||
handle?.SetMessage("正在编译");
|
||||
try
|
||||
{
|
||||
if (Installed is false)
|
||||
|
@ -125,7 +119,7 @@ namespace BITKit
|
|||
// CreateNoWindow = false,
|
||||
// };
|
||||
|
||||
var StartInfo = new ProcessStartInfo
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
//FileName = MCSPath,
|
||||
FileName = "dotnet",
|
||||
|
@ -142,7 +136,7 @@ namespace BITKit
|
|||
|
||||
var process = new Process()
|
||||
{
|
||||
StartInfo = StartInfo,
|
||||
StartInfo = startInfo,
|
||||
};
|
||||
var reportBuilder = new StringBuilder();
|
||||
process.OutputDataReceived += (sender, args) =>
|
||||
|
@ -184,14 +178,10 @@ namespace BITKit
|
|||
|
||||
BIT4Log.Log<BITSharp>(reportBuilder);
|
||||
|
||||
waiting?.Release(handle);
|
||||
|
||||
return Assembly.Load(bytes);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
waiting?.Release(handle);
|
||||
|
||||
throw new Exception($"编译失败:{e}");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue