mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
Update
Update
This commit is contained in:
@@ -19,21 +19,6 @@ namespace TEngine.Core.Network
|
||||
private static readonly Dictionary<long, Session> Sessions = new ();
|
||||
public readonly Dictionary<long, FTask<IResponse>> RequestCallback = new();
|
||||
|
||||
#if TENGINE_UNITY
|
||||
public delegate void CsMsgDelegate(IResponse msg);
|
||||
|
||||
public readonly Dictionary<uint, CsMsgDelegate> MsgHandles = new Dictionary<uint, CsMsgDelegate>();
|
||||
|
||||
public void RegisterMsgHandler(uint protocolCode,CsMsgDelegate ctx)
|
||||
{
|
||||
if (MsgHandles.ContainsKey(protocolCode))
|
||||
{
|
||||
return;
|
||||
}
|
||||
MsgHandles.Add(protocolCode,ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void Create(ANetworkMessageScheduler networkMessageScheduler, ANetworkChannel channel)
|
||||
{
|
||||
#if TENGINE_DEVELOP
|
||||
|
@@ -34,6 +34,28 @@ namespace TEngine.Core.Network
|
||||
#endif
|
||||
private static readonly CoroutineLockQueueType ReceiveRouteMessageLock = new CoroutineLockQueueType("ReceiveRouteMessageLock");
|
||||
|
||||
#if TENGINE_UNITY
|
||||
|
||||
public readonly Dictionary<uint, List<Action<IResponse>>> MsgHandles = new Dictionary<uint, List<Action<IResponse>>>();
|
||||
|
||||
public void RegisterMsgHandler(uint protocolCode,Action<IResponse> ctx)
|
||||
{
|
||||
if (!MsgHandles.ContainsKey(protocolCode))
|
||||
{
|
||||
MsgHandles[protocolCode] = new List<Action<IResponse>>();
|
||||
}
|
||||
MsgHandles[protocolCode].Add(ctx);
|
||||
}
|
||||
|
||||
public void UnRegisterMsgHandler(uint protocolCode,Action<IResponse> ctx)
|
||||
{
|
||||
if (MsgHandles.TryGetValue(protocolCode, out var handle))
|
||||
{
|
||||
handle.Remove(ctx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override void OnLoad(int assemblyName)
|
||||
{
|
||||
foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(IMessage)))
|
||||
|
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Codice.Client.GameUI.Explorer;
|
||||
using TEngine.Core;
|
||||
#pragma warning disable CS8600
|
||||
|
||||
@@ -58,9 +57,12 @@ namespace TEngine.Core.Network
|
||||
#else
|
||||
|
||||
#if TENGINE_UNITY
|
||||
if (session.MsgHandles.TryGetValue(packInfo.ProtocolCode,out var msgDelegate))
|
||||
if (MessageDispatcherSystem.Instance.MsgHandles.TryGetValue(packInfo.ProtocolCode,out var msgDelegates))
|
||||
{
|
||||
msgDelegate.Invoke(aResponse);
|
||||
foreach (var msgDelegate in msgDelegates)
|
||||
{
|
||||
msgDelegate.Invoke(aResponse);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user