1
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using BITKit.Net.Examples;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
@@ -456,12 +457,17 @@ namespace BITKit.Net
|
||||
|
||||
public void AddRpcHandle(object rpcHandle)
|
||||
{
|
||||
var reportBuilder = new StringBuilder();
|
||||
|
||||
reportBuilder.AppendLine($"正在通过反射注册{rpcHandle.GetType().Name}");
|
||||
foreach (var methodInfo in rpcHandle.GetType().GetMethods())
|
||||
{
|
||||
var att = methodInfo.GetCustomAttribute<NetRpcAttribute>();
|
||||
if(att is null)continue;
|
||||
_rpcMethods.AddOrUpdate(methodInfo.Name, methodInfo, (s, info) => methodInfo);
|
||||
_rpcHandles.AddOrUpdate(methodInfo.Name, rpcHandle, (s, o) => rpcHandle);
|
||||
|
||||
reportBuilder.AppendLine($"Add [{methodInfo.Name}] as MethodInfo");
|
||||
}
|
||||
|
||||
foreach (var eventInfo in rpcHandle.GetType().GetEvents())
|
||||
@@ -470,7 +476,12 @@ namespace BITKit.Net
|
||||
if(att is null)continue;
|
||||
var handle = eventInfo.EventHandlerType.GetMethod("Invoke");
|
||||
_rpcMethods.AddOrUpdate(handle.Name, handle, (s, info) => handle);
|
||||
_rpcHandles.AddOrUpdate(handle.Name, rpcHandle, (s, info) => rpcHandle);
|
||||
|
||||
reportBuilder.AppendLine($"Add [{eventInfo.Name} as EventInfo]");
|
||||
}
|
||||
|
||||
BIT4Log.Log<KcpNetClient>(reportBuilder);
|
||||
}
|
||||
|
||||
public void AddCommandListener<T>(Action<T> handle)
|
||||
|
Reference in New Issue
Block a user