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,6 +19,21 @@ 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
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Codice.Client.GameUI.Explorer;
|
||||
using TEngine.Core;
|
||||
#pragma warning disable CS8600
|
||||
|
||||
@@ -55,6 +56,14 @@ namespace TEngine.Core.Network
|
||||
// 服务器之间发送消息因为走的是MessageHelper、所以接收消息的回调也应该放到MessageHelper里处理
|
||||
MessageHelper.ResponseHandler(packInfo.RpcId, aResponse);
|
||||
#else
|
||||
|
||||
#if TENGINE_UNITY
|
||||
if (session.MsgHandles.TryGetValue(packInfo.ProtocolCode,out var msgDelegate))
|
||||
{
|
||||
msgDelegate.Invoke(aResponse);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// 这个一般是客户端Session.Call发送时使用的、目前这个逻辑只有Unity客户端时使用
|
||||
|
||||
if (!session.RequestCallback.TryGetValue(packInfo.RpcId, out var action))
|
||||
|
Reference in New Issue
Block a user