ソースを参照

把消息方面的独立

hexiaojie 8 ヶ月 前
コミット
9e74853fd6
21 ファイル変更691 行追加15 行削除
  1. 8 0
      GameClient/Assets/Game/HotUpdate/Message.meta
  2. 99 0
      GameClient/Assets/Game/HotUpdate/Message/MessageDispatcherComponentSystem.cs
  3. 11 0
      GameClient/Assets/Game/HotUpdate/Message/MessageDispatcherComponentSystem.cs.meta
  4. 104 0
      GameClient/Assets/Game/HotUpdate/Message/NetKcpComponentSystem.cs
  5. 11 0
      GameClient/Assets/Game/HotUpdate/Message/NetKcpComponentSystem.cs.meta
  6. 72 0
      GameClient/Assets/Game/HotUpdate/Message/NetThreadComponentSystem.cs
  7. 11 0
      GameClient/Assets/Game/HotUpdate/Message/NetThreadComponentSystem.cs.meta
  8. 134 0
      GameClient/Assets/Game/HotUpdate/Message/NetWSComponentAwakeSystem.cs
  9. 11 0
      GameClient/Assets/Game/HotUpdate/Message/NetWSComponentAwakeSystem.cs.meta
  10. 41 0
      GameClient/Assets/Game/HotUpdate/Message/SessionAcceptTimeoutComponentSystem.cs
  11. 11 0
      GameClient/Assets/Game/HotUpdate/Message/SessionAcceptTimeoutComponentSystem.cs.meta
  12. 57 0
      GameClient/Assets/Game/HotUpdate/Message/SessionIdleCheckerComponentSystem.cs
  13. 11 0
      GameClient/Assets/Game/HotUpdate/Message/SessionIdleCheckerComponentSystem.cs.meta
  14. 84 0
      GameClient/Assets/Game/HotUpdate/Message/SessionStreamDispatcherSystem.cs
  15. 11 0
      GameClient/Assets/Game/HotUpdate/Message/SessionStreamDispatcherSystem.cs.meta
  16. 2 2
      GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoDataManager.cs
  17. 4 4
      GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoEntryView.cs
  18. 2 2
      GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoSuccessView.cs
  19. 2 2
      GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoTargetView.cs
  20. 3 3
      GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoView.cs
  21. 2 2
      GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityZLFGRewardTips.cs

+ 8 - 0
GameClient/Assets/Game/HotUpdate/Message.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 624118359161bd44a84d6b3097c4869f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 99 - 0
GameClient/Assets/Game/HotUpdate/Message/MessageDispatcherComponentSystem.cs

@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+
+namespace ET
+{
+    [ObjectSystem]
+    public class MessageDispatcherComponentAwakeSystem: AwakeSystem<MessageDispatcherComponent>
+    {
+        public override void Awake(MessageDispatcherComponent self)
+        {
+            MessageDispatcherComponent.Instance = self;
+            self.Load();
+        }
+    }
+
+    [ObjectSystem]
+    public class MessageDispatcherComponentLoadSystem: LoadSystem<MessageDispatcherComponent>
+    {
+        public override void Load(MessageDispatcherComponent self)
+        {
+            self.Load();
+        }
+    }
+
+    [ObjectSystem]
+    public class MessageDispatcherComponentDestroySystem: DestroySystem<MessageDispatcherComponent>
+    {
+        public override void Destroy(MessageDispatcherComponent self)
+        {
+            MessageDispatcherComponent.Instance = null;
+            self.Handlers.Clear();
+        }
+    }
+
+    /// <summary>
+    /// 消息分发组件
+    /// </summary>
+    public static class MessageDispatcherComponentHelper
+    {
+        public static void Load(this MessageDispatcherComponent self)
+        {
+            self.Handlers.Clear();
+
+            HashSet<Type> types = Game.EventSystem.GetTypes(typeof (MessageHandlerAttribute));
+
+            foreach (Type type in types)
+            {
+                IMHandler iMHandler = Activator.CreateInstance(type) as IMHandler;
+                if (iMHandler == null)
+                {
+                    Log.Error($"message handle {type.Name} 需要继承 IMHandler");
+                    continue;
+                }
+
+                Type messageType = iMHandler.GetMessageType();
+                ushort opcode = OpcodeTypeComponent.Instance.GetOpcode(messageType);
+                if (opcode == 0)
+                {
+                    Log.Error($"消息opcode为0: {messageType.Name}");
+                    continue;
+                }
+
+                self.RegisterHandler(opcode, iMHandler);
+            }
+        }
+
+        public static void RegisterHandler(this MessageDispatcherComponent self, ushort opcode, IMHandler handler)
+        {
+            if (!self.Handlers.ContainsKey(opcode))
+            {
+                self.Handlers.Add(opcode, new List<IMHandler>());
+            }
+
+            self.Handlers[opcode].Add(handler);
+        }
+
+        public static void Handle(this MessageDispatcherComponent self, Session session, ushort opcode, object message)
+        {
+            List<IMHandler> actions;
+            if (!self.Handlers.TryGetValue(opcode, out actions))
+            {
+                Log.Error($"消息没有处理: {opcode} {message}");
+                return;
+            }
+
+            foreach (IMHandler ev in actions)
+            {
+                try
+                {
+                    ev.Handle(session, message);
+                }
+                catch (Exception e)
+                {
+                    Log.Error(e);
+                }
+            }
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/MessageDispatcherComponentSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 491b33626f6f30a46b106ff39ab8a5fa
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 104 - 0
GameClient/Assets/Game/HotUpdate/Message/NetKcpComponentSystem.cs

@@ -0,0 +1,104 @@
+// using System;
+// using System.IO;
+// using System.Net;
+//
+// namespace ET
+// {
+//     [ObjectSystem]
+//     public class NetKcpComponentAwakeSystem: AwakeSystem<NetKcpComponent, int>
+//     {
+//         public override void Awake(NetKcpComponent self, int sessionStreamDispatcherType)
+//         {
+//             self.SessionStreamDispatcherType = sessionStreamDispatcherType;
+//             
+//             self.Service = new TService(NetThreadComponent.Instance.ThreadSynchronizationContext, ServiceType.Outer);
+//             self.Service.ErrorCallback += (channelId, error) => self.OnError(channelId, error);
+//             self.Service.ReadCallback += (channelId, Memory) => self.OnRead(channelId, Memory);
+//
+//             NetThreadComponent.Instance.Add(self.Service);
+//         }
+//     }
+//
+//     [ObjectSystem]
+//     public class NetKcpComponentAwake1System: AwakeSystem<NetKcpComponent, IPEndPoint, int>
+//     {
+//         public override void Awake(NetKcpComponent self, IPEndPoint address, int sessionStreamDispatcherType)
+//         {
+//             self.SessionStreamDispatcherType = sessionStreamDispatcherType;
+//             
+//             self.Service = new TService(NetThreadComponent.Instance.ThreadSynchronizationContext, address, ServiceType.Outer);
+//             self.Service.ErrorCallback += (channelId, error) => self.OnError(channelId, error);
+//             self.Service.ReadCallback += (channelId, Memory) => self.OnRead(channelId, Memory);
+//             self.Service.AcceptCallback += (channelId, IPAddress) => self.OnAccept(channelId, IPAddress);
+//
+//             NetThreadComponent.Instance.Add(self.Service);
+//         }
+//     }
+//
+//     [ObjectSystem]
+//     public class NetKcpComponentDestroySystem: DestroySystem<NetKcpComponent>
+//     {
+//         public override void Destroy(NetKcpComponent self)
+//         {
+//             NetThreadComponent.Instance.Remove(self.Service);
+//             self.Service.Destroy();
+//         }
+//     }
+//
+//     public static class NetKcpComponentSystem
+//     {
+//         public static void OnRead(this NetKcpComponent self, long channelId, MemoryStream memoryStream)
+//         {
+//             Session session = self.GetChild<Session>(channelId);
+//             if (session == null)
+//             {
+//                 return;
+//             }
+//
+//             session.LastRecvTime = TimeHelper.ClientNow();
+//             SessionStreamDispatcher.Instance.Dispatch(self.SessionStreamDispatcherType, session, memoryStream);
+//         }
+//
+//         public static void OnError(this NetKcpComponent self, long channelId, int error)
+//         {
+//             Session session = self.GetChild<Session>(channelId);
+//             if (session == null)
+//             {
+//                 return;
+//             }
+//
+//             session.Error = error;
+//             session.Dispose();
+//         }
+//
+//         // 这个channelId是由CreateAcceptChannelId生成的
+//         public static void OnAccept(this NetKcpComponent self, long channelId, IPEndPoint ipEndPoint)
+//         {
+//             Session session = self.AddChildWithId<Session, AService>(channelId, self.Service);
+//             session.RemoteAddress = ipEndPoint;
+//
+//             // 挂上这个组件,5秒就会删除session,所以客户端验证完成要删除这个组件。该组件的作用就是防止外挂一直连接不发消息也不进行权限验证
+//             session.AddComponent<SessionAcceptTimeoutComponent>();
+//             // 客户端连接,2秒检查一次recv消息,10秒没有消息则断开
+//             session.AddComponent<SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral);
+//         }
+//
+//         public static Session Get(this NetKcpComponent self, long id)
+//         {
+//             Session session = self.GetChild<Session>(id);
+//             return session;
+//         }
+//
+//         public static Session Create(this NetKcpComponent self, IPEndPoint realIPEndPoint)
+//         {
+//             long channelId = RandomHelper.RandInt64();
+//             Session session = self.AddChildWithId<Session, AService>(channelId, self.Service);
+//             session.RemoteAddress = realIPEndPoint;
+//             session.AddComponent<SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral);
+//             
+//             self.Service.GetOrCreate(session.Id, realIPEndPoint);
+//
+//             return session;
+//         }
+//     }
+// }

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/NetKcpComponentSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 089ec457d5d9e684eb68d787b18d6c15
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 72 - 0
GameClient/Assets/Game/HotUpdate/Message/NetThreadComponentSystem.cs

@@ -0,0 +1,72 @@
+using System;
+using System.Threading;
+
+namespace ET
+{
+    [ObjectSystem]
+    public class NetThreadComponentAwakeSystem: AwakeSystem<NetThreadComponent>
+    {
+        public override void Awake(NetThreadComponent self)
+        {
+            NetThreadComponent.Instance = self;
+            
+            self.ThreadSynchronizationContext = ThreadSynchronizationContext.Instance;
+        }
+    }
+
+    [ObjectSystem]
+    public class NetThreadComponentUpdateSystem: LateUpdateSystem<NetThreadComponent>
+    {
+        public override void LateUpdate(NetThreadComponent self)
+        {
+            foreach (AService service in self.Services)
+            {
+                service.Update();
+            }
+        }
+    }
+    
+    [ObjectSystem]
+    public class NetThreadComponentDestroySystem: DestroySystem<NetThreadComponent>
+    {
+        public override void Destroy(NetThreadComponent self)
+        {
+            self.Stop();
+        }
+    }
+    
+    public static class NetThreadComponentSystem
+    {
+
+        public static void Stop(this NetThreadComponent self)
+        {
+        }
+
+        public static void Add(this NetThreadComponent self, AService kService)
+        {
+            // 这里要去下一帧添加,避免foreach错误
+            self.ThreadSynchronizationContext.PostNext(() =>
+            {
+                if (kService.IsDisposed())
+                {
+                    return;
+                }
+                self.Services.Add(kService);
+            });
+        }
+        
+        public static void Remove(this NetThreadComponent self, AService kService)
+        {
+            // 这里要去下一帧删除,避免foreach错误
+            self.ThreadSynchronizationContext.PostNext(() =>
+            {
+                if (kService.IsDisposed())
+                {
+                    return;
+                }
+                self.Services.Remove(kService);
+            });
+        }
+        
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/NetThreadComponentSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5493e9b57b1de154e8a82f15590f837e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 134 - 0
GameClient/Assets/Game/HotUpdate/Message/NetWSComponentAwakeSystem.cs

@@ -0,0 +1,134 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ET
+
+{
+    [ObjectSystem]
+    public class NetWSComponentAwakeSystem : AwakeSystem<NetWSComponent, int>
+
+    {
+        public override void Awake(NetWSComponent self, int sessionStreamDispatcherType)
+        {
+            self.SessionStreamDispatcherType = sessionStreamDispatcherType;
+
+            self.AService = new WService();
+            self.AService.ReadCallback = self.OnRead;
+            self.AService.ErrorCallback = self.OnError;
+        }
+    }
+
+
+    [ObjectSystem]
+    public class NetWSComponentAwake1System : AwakeSystem<NetWSComponent, IEnumerable<string>>
+
+    {
+        public override void Awake(NetWSComponent self, IEnumerable<string> prefixs)
+        {
+            self.AService = new WService(prefixs);
+
+            self.AService.ErrorCallback += (channelId, error) => self.OnError(channelId, error);
+
+            self.AService.ReadCallback += (channelId, Memory) => self.OnRead(channelId, Memory);
+
+            self.AService.AcceptCallback += (channelId, IPAddress) => self.OnAccept(channelId, IPAddress);
+
+            NetThreadComponent.Instance.Add(self.AService);
+        }
+    }
+
+    [ObjectSystem]
+    public class NetWSComponentDestroySystem : DestroySystem<NetWSComponent>
+
+    {
+        public override void Destroy(NetWSComponent self)
+
+        {
+            self.AService.Dispose();
+        }
+    }
+
+
+    public static class NetWSComponentSystem
+
+    {
+        public static void OnRead(this NetWSComponent self, long channelId, MemoryStream memoryStream)
+
+        {
+            Session session = self.GetChild<Session>(channelId);
+
+            if (session == null)
+
+            {
+                return;
+            }
+
+            session.LastRecvTime = TimeHelper.ClientNow();
+
+            SessionStreamDispatcher.Instance.Dispatch(self.SessionStreamDispatcherType, session, memoryStream);
+        }
+
+        public static void OnError(this NetWSComponent self, long channelId, int error)
+
+        {
+            Session session = self.GetChild<Session>(channelId);
+
+            if (session == null)
+
+            {
+                return;
+            }
+
+            session.Error = error;
+
+            session.Dispose();
+        }
+
+        // 这个channelId是由CreateAcceptChannelId生成的
+
+        public static void OnAccept(this NetWSComponent self, long channelId, IPEndPoint ipEndPoint)
+
+        {
+            Session session = self.AddChildWithId<Session, AService>(channelId, self.AService);
+
+            session.RemoteAddress = ipEndPoint;
+
+            // 挂上这个组件,5秒就会删除session,所以客户端验证完成要删除这个组件。该组件的作用就是防止外挂一直连接不发消息也不进行权限验证
+
+            session.AddComponent<SessionAcceptTimeoutComponent>();
+
+            // 客户端连接,2秒检查一次recv消息,10秒没有消息则断开
+
+            session.AddComponent<SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral);
+        }
+
+        public static Session Get(this NetWSComponent self, long id)
+
+        {
+            Session session = self.GetChild<Session>(id);
+
+            return session;
+        }
+
+        public static Session Create(this NetWSComponent self, IPEndPoint realIPEndPoint, string address)
+
+        {
+            long channelId = RandomHelper.RandInt64();
+
+            Session session = self.AddChildWithId<Session, AService>(channelId, self.AService);
+
+            session.RemoteAddress = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
+
+            session.AddComponent<SessionIdleCheckerComponent, int>(NetThreadComponent.checkInteral);
+
+            self.AService.Create(session.Id, realIPEndPoint, address);
+
+            return session;
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/NetWSComponentAwakeSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: cc37913acaed7594f94f486865c909e4
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 41 - 0
GameClient/Assets/Game/HotUpdate/Message/SessionAcceptTimeoutComponentSystem.cs

@@ -0,0 +1,41 @@
+using System;
+
+namespace ET
+{
+    [Timer(TimerType.SessionAcceptTimeout)]
+    public class SessionAcceptTimeout : ATimer<SessionAcceptTimeoutComponent>
+    {
+        public override void Run(SessionAcceptTimeoutComponent self)
+        {
+            try
+            {
+                Log.Info("断开连接");
+                self.Parent.Dispose();
+            }
+            catch (Exception e)
+            {
+                Log.Error($"move timer error: {self.Id}\n{e}");
+            }
+        }
+    }
+
+    [ObjectSystem]
+    public class SessionAcceptTimeoutComponentAwakeSystem : AwakeSystem<SessionAcceptTimeoutComponent>
+    {
+        public override void Awake(SessionAcceptTimeoutComponent self)
+        {
+            self.Timer =
+                TimerComponent.Instance.NewOnceTimer(TimeHelper.ServerNow() + 5000, TimerType.SessionAcceptTimeout,
+                    self);
+        }
+    }
+
+    [ObjectSystem]
+    public class SessionAcceptTimeoutComponentDestroySystem : DestroySystem<SessionAcceptTimeoutComponent>
+    {
+        public override void Destroy(SessionAcceptTimeoutComponent self)
+        {
+            TimerComponent.Instance.Remove(ref self.Timer);
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/SessionAcceptTimeoutComponentSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ebeca8e7394d39f4ea45dc49e1337db3
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 57 - 0
GameClient/Assets/Game/HotUpdate/Message/SessionIdleCheckerComponentSystem.cs

@@ -0,0 +1,57 @@
+using System;
+
+namespace ET
+{
+    [Timer(TimerType.SessionIdleChecker)]
+    public class SessionIdleChecker: ATimer<SessionIdleCheckerComponent>
+    {
+        public override void Run(SessionIdleCheckerComponent self)
+        {
+            try
+            {
+                self.Check();
+            }
+            catch (Exception e)
+            {
+                Log.Error($"move timer error: {self.Id}\n{e}");
+            }
+        }
+    }
+    
+    [ObjectSystem]
+    public class SessionIdleCheckerComponentAwakeSystem: AwakeSystem<SessionIdleCheckerComponent, int>
+    {
+        public override void Awake(SessionIdleCheckerComponent self, int checkInteral)
+        {
+            self.RepeatedTimer = TimerComponent.Instance.NewRepeatedTimer(checkInteral, TimerType.SessionIdleChecker, self);
+        }
+    }
+
+    [ObjectSystem]
+    public class SessionIdleCheckerComponentDestroySystem: DestroySystem<SessionIdleCheckerComponent>
+    {
+        public override void Destroy(SessionIdleCheckerComponent self)
+        {
+            TimerComponent.Instance?.Remove(ref self.RepeatedTimer);
+        }
+    }
+
+    public static class SessionIdleCheckerComponentSystem
+    {
+        public static void Check(this SessionIdleCheckerComponent self)
+        {
+            Session session = self.GetParent<Session>();
+            long timeNow = TimeHelper.ClientNow();
+
+            if (timeNow - session.LastRecvTime < 60 * 1000 && timeNow - session.LastSendTime < 60 * 1000)
+            {
+                return;
+            }
+            Log.Info(
+                $"session timeout: {session.Id} {timeNow} {session.LastRecvTime} {session.LastSendTime} {timeNow - session.LastRecvTime} {timeNow - session.LastSendTime}");
+            session.Error = ErrorCore.ERR_SessionSendOrRecvTimeout;
+
+            session.Dispose();
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/SessionIdleCheckerComponentSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9423023072524864d802173306de4d35
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 84 - 0
GameClient/Assets/Game/HotUpdate/Message/SessionStreamDispatcherSystem.cs

@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace ET
+{
+    [ObjectSystem]
+    public class SessionStreamDispatcherAwakeSystem: AwakeSystem<SessionStreamDispatcher>
+    {
+        public override void Awake(SessionStreamDispatcher self)
+        {
+            SessionStreamDispatcher.Instance = self;
+            self.Load();
+        }
+    }
+
+    [ObjectSystem]
+    public class SessionStreamDispatcherLoadSystem: LoadSystem<SessionStreamDispatcher>
+    {
+        public override void Load(SessionStreamDispatcher self)
+        {
+            self.Load();
+        }
+    }
+
+    [ObjectSystem]
+    public class SessionStreamDispatcherDestroySystem: DestroySystem<SessionStreamDispatcher>
+    {
+        public override void Destroy(SessionStreamDispatcher self)
+        {
+            SessionStreamDispatcher.Instance = null;
+        }
+    }
+    
+    public static class SessionStreamDispatcherSystem
+    {
+        public static void Load(this SessionStreamDispatcher self)
+        {
+            self.Dispatchers = new ISessionStreamDispatcher[100];
+            
+            HashSet<Type> types = Game.EventSystem.GetTypes(typeof (SessionStreamDispatcherAttribute));
+
+            foreach (Type type in types)
+            {
+                object[] attrs = type.GetCustomAttributes(typeof (SessionStreamDispatcherAttribute), false);
+                if (attrs.Length == 0)
+                {
+                    continue;
+                }
+                
+                SessionStreamDispatcherAttribute sessionStreamDispatcherAttribute = attrs[0] as SessionStreamDispatcherAttribute;
+                if (sessionStreamDispatcherAttribute == null)
+                {
+                    continue;
+                }
+
+                if (sessionStreamDispatcherAttribute.Type >= 100)
+                {
+                    Log.Error("session dispatcher type must < 100");
+                    continue;
+                }
+                
+                ISessionStreamDispatcher iSessionStreamDispatcher = Activator.CreateInstance(type) as ISessionStreamDispatcher;
+                if (iSessionStreamDispatcher == null)
+                {
+                    Log.Error($"sessionDispatcher {type.Name} 需要继承 ISessionDispatcher");
+                    continue;
+                }
+
+                self.Dispatchers[sessionStreamDispatcherAttribute.Type] = iSessionStreamDispatcher;
+            }
+        }
+
+        public static void Dispatch(this SessionStreamDispatcher self, int type, Session session, MemoryStream memoryStream)
+        {
+            ISessionStreamDispatcher sessionStreamDispatcher = self.Dispatchers[type];
+            if (sessionStreamDispatcher == null)
+            {
+                throw new Exception("maybe your NetInnerComponent or NetOuterComponent not set SessionStreamDispatcherType");
+            }
+            sessionStreamDispatcher.Dispatch(session, memoryStream);
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Message/SessionStreamDispatcherSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1c6061ff2ed639943aa48493fffec10c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoDataManager.cs

@@ -25,10 +25,10 @@ namespace GFGGame
 
 
             long haveNum =
-                ItemDataManager.GetItemNum(CommonDataManager.Tables.TblPickUpGame.DataList[curLevel].ComsumePass[0]
+                ItemDataManager.GetItemNum(CommonDataManager.Tables.TblPickUpGameCfg.DataList[curLevel].ComsumePass[0]
                     .ItemId);
 
-            bool canPlay = (haveNum >= CommonDataManager.Tables.TblPickUpGame.DataList[curLevel].ComsumePass[0].Count);
+            bool canPlay = (haveNum >= CommonDataManager.Tables.TblPickUpGameCfg.DataList[curLevel].ComsumePass[0].Count);
 
             return canPlay;
         }

+ 4 - 4
GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoEntryView.cs

@@ -116,7 +116,7 @@ namespace GFGGame
         {
             item.data = index;
             UI_level level = UI_level.Proxy(item);
-            PickUpGame pickUpGame = CommonDataManager.Tables.TblPickUpGame.DataList[index];
+            PickUpGameCfg pickUpGame = CommonDataManager.Tables.TblPickUpGameCfg.DataList[index];
 
             level.m_spendIcon.url =
                 ResPathUtil.GetIconPath(
@@ -151,7 +151,7 @@ namespace GFGGame
             }
 
             index = id;
-            PickUpGame cfg = CommonDataManager.Tables.TblPickUpGame.DataList[id];
+            PickUpGameCfg cfg = CommonDataManager.Tables.TblPickUpGameCfg.DataList[id];
             ViewManager.Show<ActivityZLFGRewardTips>(cfg);
         }
 
@@ -182,7 +182,7 @@ namespace GFGGame
                 return;
             }
             
-            PickUpGame cfg = CommonDataManager.Tables.TblPickUpGame.DataList[_ui.m_list.selectedIndex];
+            PickUpGameCfg cfg = CommonDataManager.Tables.TblPickUpGameCfg.DataList[_ui.m_list.selectedIndex];
             ViewManager.Show<ActivityGetYuanXiaoTargetView>(cfg);
         }
 
@@ -190,7 +190,7 @@ namespace GFGGame
         {
             int activityID = ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityType.YuanXiao);
 
-            PickUpGame cfg = CommonDataManager.Tables.TblPickUpGame.DataList[_ui.m_list.selectedIndex];
+            PickUpGameCfg cfg = CommonDataManager.Tables.TblPickUpGameCfg.DataList[_ui.m_list.selectedIndex];
             var result = await MiniGameProxy.ReqMiniGameStart(cfg.Id, cfg.Type, activityID);
             if (!result || !isShowing) return;
 

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoSuccessView.cs

@@ -10,7 +10,7 @@ namespace GFGGame
     public class ActivityGetYuanXiaoSuccessView : BaseWindow
     {
         private UI_ActivityGetYuanXiaoSuccessUI _ui;
-        private PickUpGame _cfg;
+        private PickUpGameCfg _cfg;
         private List<ItemData> itemDatas;
         private Dictionary<string, EffectUI> _effectUIDic = new Dictionary<string, EffectUI>();
 
@@ -56,7 +56,7 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-            _cfg = (PickUpGame)viewData;
+            _cfg = (PickUpGameCfg)viewData;
             _ui.m_btnRetry.visible = (_cfg.IsAgain != 0);
 
             itemDatas = ItemUtil.CreateItemDataList(_cfg.BonusWin.ToGfgGameItemParam());

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoTargetView.cs

@@ -9,7 +9,7 @@ namespace GFGGame
     public class ActivityGetYuanXiaoTargetView : BaseWindow
     {
         private UI_ActivityGetYuanXiaoTargetUI _ui;
-        private PickUpGame _cfg;
+        private PickUpGameCfg _cfg;
 
         public override void Dispose()
         {
@@ -41,7 +41,7 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-            _cfg = (PickUpGame)viewData;
+            _cfg = (PickUpGameCfg)viewData;
 
             _ui.m_c1.selectedIndex = (_cfg.TargetId.Count == 0 ? 1 : 0);
             if (_ui.m_c1.selectedIndex == 0)

+ 3 - 3
GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityGetYuanXiaoView.cs

@@ -12,7 +12,7 @@ namespace GFGGame
     {
         private UI_ActivityGetYuanXiaoUI _ui;
         private List<YuanXiaoItem> items = new List<YuanXiaoItem>();
-        private PickUpGame _cfg;
+        private PickUpGameCfg _cfg;
         private int _activityID;
         private int _countTime;
         private int _score;
@@ -61,7 +61,7 @@ namespace GFGGame
         {
             base.OnShown();
             object[] arr = viewData as object[];
-            _cfg = (PickUpGame)arr[0];
+            _cfg = (PickUpGameCfg)arr[0];
             _activityID = (int)arr[1];
 
             if (_firstIn)
@@ -342,7 +342,7 @@ namespace GFGGame
             _ui.m_startEffect.visible = false;
             _ui.m_catcher.m_getEffect.visible = false;
             _ui.m_catcher.m_flyscore.target.visible = false;
-            _ui.m_catcher.m_c2.selectedIndex = _cfg.Id > CommonDataManager.Tables.TblPickUpGame.DataList[0].Id ? 1 : 0;
+            _ui.m_catcher.m_c2.selectedIndex = _cfg.Id > CommonDataManager.Tables.TblPickUpGameCfg.DataList[0].Id ? 1 : 0;
 
             _ui.m_time.text = TimeUtil.FormattingTimeTo_mmss(_countTime * 1000);
             _ui.m_score.text = _score.ToString();

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/ActivityGetYuanXiao/ActivityZLFGRewardTips.cs

@@ -10,7 +10,7 @@ namespace GFGGame
     class ActivityZLFGRewardTips : BaseWindow
     {
         private UI_RewardTipsUI _ui;
-        private PickUpGame _cfg;
+        private PickUpGameCfg _cfg;
 
         public override void Dispose()
         {
@@ -40,7 +40,7 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-            _cfg = (PickUpGame)this.viewData;
+            _cfg = (PickUpGameCfg)this.viewData;
             _ui.m_rewardList.numItems = _cfg.BonusWin.Count;
         }