Переглянути джерело

1.消除网络消息的GC
2.消除MultiMap的GC
3.消除Unity中的KService的TimerGC
4.最后还剩下TimerComonent有个136B的GC,主要是SortedDictinary导致的,这个准备后面替换

tanghai 2 роки тому
батько
коміт
563251fdf2
26 змінених файлів з 454 додано та 239 видалено
  1. 1 1
      Share/Tool/Proto2CS/Proto2CS.cs
  2. 36 36
      Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/OuterMessage_C_10001.cs
  3. 23 23
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/InnerMessage_S_20001.cs
  4. 36 36
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/OuterMessage_C_10001.cs
  5. 23 23
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/InnerMessage_S_20001.cs
  6. 36 36
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/OuterMessage_C_10001.cs
  7. 2 0
      Unity/Assets/Scripts/Codes/Model/Share/Module/Message/OpcodeHelper.cs
  8. 1 1
      Unity/Assets/Scripts/Codes/Model/Share/Module/Message/Session.cs
  9. 21 23
      Unity/Assets/Scripts/Core/Module/Network/AService.cs
  10. 14 5
      Unity/Assets/Scripts/Core/Module/Network/KChannel.cs
  11. 13 4
      Unity/Assets/Scripts/Core/Module/Network/KService.cs
  12. 65 0
      Unity/Assets/Scripts/Core/Module/Network/MessagePool.cs
  13. 11 0
      Unity/Assets/Scripts/Core/Module/Network/MessagePool.cs.meta
  14. 33 7
      Unity/Assets/Scripts/Core/Module/Network/NetServices.cs
  15. 3 1
      Unity/Assets/Scripts/Core/Module/Network/TChannel.cs
  16. 3 3
      Unity/Assets/Scripts/Core/Module/Network/TService.cs
  17. 11 6
      Unity/Assets/Scripts/Core/Module/Network/WChannel.cs
  18. 2 3
      Unity/Assets/Scripts/Core/Module/Network/WService.cs
  19. 1 1
      Unity/Assets/Scripts/Core/Module/ObjectPool/ObjectPool.cs
  20. 1 1
      Unity/Assets/Scripts/Core/Module/Timer/TimerComponent.cs
  21. 45 2
      Unity/Assets/Scripts/Core/MultiMap.cs
  22. 10 0
      Unity/Assets/Scripts/Core/Object/MessageObject.cs
  23. 11 0
      Unity/Assets/Scripts/Core/Object/MessageObject.cs.meta
  24. 7 6
      Unity/Assets/Scripts/Core/Serialize/MemoryBuffer.cs
  25. 26 6
      Unity/Assets/Scripts/Core/Serialize/MemoryPackHelper.cs
  26. 19 15
      Unity/Assets/Scripts/Core/Serialize/SerializeHelper.cs

+ 1 - 1
Share/Tool/Proto2CS/Proto2CS.cs

@@ -121,7 +121,7 @@ namespace ET
                     sb.Append($"\t[Message({protoName}.{msgName})]\n");
                     sb.Append($"\t[ProtoContract]\n");
                     sb.Append($"\t[MemoryPackable]\n");
-                    sb.Append($"\tpublic partial class {msgName}: ProtoObject");
+                    sb.Append($"\tpublic partial class {msgName}: MessageObject");
                     if (parentClass == "IActorMessage" || parentClass == "IActorRequest" || parentClass == "IActorResponse")
                     {
                         sb.Append($", {parentClass}\n");

+ 36 - 36
Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/OuterMessage_C_10001.cs

@@ -7,7 +7,7 @@ namespace ET
 	[Message(OuterMessage.HttpGetRouterResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class HttpGetRouterResponse: ProtoObject
+	public partial class HttpGetRouterResponse: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -22,7 +22,7 @@ namespace ET
 	[Message(OuterMessage.RouterSync)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class RouterSync: ProtoObject
+	public partial class RouterSync: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -38,7 +38,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRequest: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRequest: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -53,7 +53,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestResponse: ProtoObject, IActorResponse
+	public partial class M2C_TestResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -77,7 +77,7 @@ namespace ET
 	[Message(OuterMessage.Actor_TransferRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class Actor_TransferRequest: ProtoObject, IActorLocationRequest
+	public partial class Actor_TransferRequest: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -92,7 +92,7 @@ namespace ET
 	[Message(OuterMessage.Actor_TransferResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class Actor_TransferResponse: ProtoObject, IActorLocationResponse
+	public partial class Actor_TransferResponse: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -112,7 +112,7 @@ namespace ET
 	[Message(OuterMessage.C2G_EnterMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_EnterMap: ProtoObject, IRequest
+	public partial class C2G_EnterMap: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -123,7 +123,7 @@ namespace ET
 	[Message(OuterMessage.G2C_EnterMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_EnterMap: ProtoObject, IResponse
+	public partial class G2C_EnterMap: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -147,7 +147,7 @@ namespace ET
 	[Message(OuterMessage.MoveInfo)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class MoveInfo: ProtoObject
+	public partial class MoveInfo: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -166,7 +166,7 @@ namespace ET
 	[Message(OuterMessage.UnitInfo)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class UnitInfo: ProtoObject
+	public partial class UnitInfo: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -201,7 +201,7 @@ namespace ET
 	[Message(OuterMessage.M2C_CreateUnits)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
+	public partial class M2C_CreateUnits: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -212,7 +212,7 @@ namespace ET
 	[Message(OuterMessage.M2C_CreateMyUnit)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_CreateMyUnit: ProtoObject, IActorMessage
+	public partial class M2C_CreateMyUnit: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -223,7 +223,7 @@ namespace ET
 	[Message(OuterMessage.M2C_StartSceneChange)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_StartSceneChange: ProtoObject, IActorMessage
+	public partial class M2C_StartSceneChange: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -238,7 +238,7 @@ namespace ET
 	[Message(OuterMessage.M2C_RemoveUnits)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
+	public partial class M2C_RemoveUnits: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -249,7 +249,7 @@ namespace ET
 	[Message(OuterMessage.C2M_PathfindingResult)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_PathfindingResult: ProtoObject, IActorLocationMessage
+	public partial class C2M_PathfindingResult: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -264,7 +264,7 @@ namespace ET
 	[Message(OuterMessage.C2M_Stop)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_Stop: ProtoObject, IActorLocationMessage
+	public partial class C2M_Stop: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -275,7 +275,7 @@ namespace ET
 	[Message(OuterMessage.M2C_PathfindingResult)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_PathfindingResult: ProtoObject, IActorMessage
+	public partial class M2C_PathfindingResult: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -294,7 +294,7 @@ namespace ET
 	[Message(OuterMessage.M2C_Stop)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_Stop: ProtoObject, IActorMessage
+	public partial class M2C_Stop: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -318,7 +318,7 @@ namespace ET
 	[Message(OuterMessage.C2G_Ping)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_Ping: ProtoObject, IRequest
+	public partial class C2G_Ping: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -329,7 +329,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Ping)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Ping: ProtoObject, IResponse
+	public partial class G2C_Ping: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -352,7 +352,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Test)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Test: ProtoObject, IMessage
+	public partial class G2C_Test: MessageObject, IMessage
 	{
 	}
 
@@ -360,7 +360,7 @@ namespace ET
 	[Message(OuterMessage.C2M_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_Reload: ProtoObject, IRequest
+	public partial class C2M_Reload: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -379,7 +379,7 @@ namespace ET
 	[Message(OuterMessage.M2C_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_Reload: ProtoObject, IResponse
+	public partial class M2C_Reload: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -399,7 +399,7 @@ namespace ET
 	[Message(OuterMessage.C2R_Login)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2R_Login: ProtoObject, IRequest
+	public partial class C2R_Login: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -418,7 +418,7 @@ namespace ET
 	[Message(OuterMessage.R2C_Login)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class R2C_Login: ProtoObject, IResponse
+	public partial class R2C_Login: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -450,7 +450,7 @@ namespace ET
 	[Message(OuterMessage.C2G_LoginGate)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_LoginGate: ProtoObject, IRequest
+	public partial class C2G_LoginGate: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -469,7 +469,7 @@ namespace ET
 	[Message(OuterMessage.G2C_LoginGate)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_LoginGate: ProtoObject, IResponse
+	public partial class G2C_LoginGate: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -492,7 +492,7 @@ namespace ET
 	[Message(OuterMessage.G2C_TestHotfixMessage)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_TestHotfixMessage: ProtoObject, IMessage
+	public partial class G2C_TestHotfixMessage: MessageObject, IMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -504,7 +504,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRobotCase)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRobotCase: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRobotCase: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -519,7 +519,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestRobotCase)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestRobotCase: ProtoObject, IActorLocationResponse
+	public partial class M2C_TestRobotCase: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -542,7 +542,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRobotCase2)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRobotCase2: ProtoObject, IActorLocationMessage
+	public partial class C2M_TestRobotCase2: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -557,7 +557,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestRobotCase2)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestRobotCase2: ProtoObject, IActorLocationMessage
+	public partial class M2C_TestRobotCase2: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -573,7 +573,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TransferMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TransferMap: ProtoObject, IActorLocationRequest
+	public partial class C2M_TransferMap: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -584,7 +584,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TransferMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TransferMap: ProtoObject, IActorLocationResponse
+	public partial class M2C_TransferMap: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -604,7 +604,7 @@ namespace ET
 	[Message(OuterMessage.C2G_Benchmark)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_Benchmark: ProtoObject, IRequest
+	public partial class C2G_Benchmark: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -615,7 +615,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Benchmark)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Benchmark: ProtoObject, IResponse
+	public partial class G2C_Benchmark: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]

+ 23 - 23
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/InnerMessage_S_20001.cs

@@ -9,7 +9,7 @@ namespace ET
 	[Message(InnerMessage.ObjectQueryRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectQueryRequest: ProtoObject, IActorRequest
+	public partial class ObjectQueryRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -29,7 +29,7 @@ namespace ET
 	[Message(InnerMessage.M2A_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2A_Reload: ProtoObject, IActorRequest
+	public partial class M2A_Reload: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -40,7 +40,7 @@ namespace ET
 	[Message(InnerMessage.A2M_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class A2M_Reload: ProtoObject, IActorResponse
+	public partial class A2M_Reload: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -60,7 +60,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockRequest: ProtoObject, IActorRequest
+	public partial class G2G_LockRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -79,7 +79,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockResponse: ProtoObject, IActorResponse
+	public partial class G2G_LockResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -99,7 +99,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockReleaseRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockReleaseRequest: ProtoObject, IActorRequest
+	public partial class G2G_LockReleaseRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -118,7 +118,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockReleaseResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockReleaseResponse: ProtoObject, IActorResponse
+	public partial class G2G_LockReleaseResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -138,7 +138,7 @@ namespace ET
 	[Message(InnerMessage.ObjectAddRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectAddRequest: ProtoObject, IActorRequest
+	public partial class ObjectAddRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -161,7 +161,7 @@ namespace ET
 	[Message(InnerMessage.ObjectAddResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectAddResponse: ProtoObject, IActorResponse
+	public partial class ObjectAddResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -181,7 +181,7 @@ namespace ET
 	[Message(InnerMessage.ObjectLockRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectLockRequest: ProtoObject, IActorRequest
+	public partial class ObjectLockRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -208,7 +208,7 @@ namespace ET
 	[Message(InnerMessage.ObjectLockResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectLockResponse: ProtoObject, IActorResponse
+	public partial class ObjectLockResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -228,7 +228,7 @@ namespace ET
 	[Message(InnerMessage.ObjectUnLockRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectUnLockRequest: ProtoObject, IActorRequest
+	public partial class ObjectUnLockRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -255,7 +255,7 @@ namespace ET
 	[Message(InnerMessage.ObjectUnLockResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectUnLockResponse: ProtoObject, IActorResponse
+	public partial class ObjectUnLockResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -275,7 +275,7 @@ namespace ET
 	[Message(InnerMessage.ObjectRemoveRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectRemoveRequest: ProtoObject, IActorRequest
+	public partial class ObjectRemoveRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -294,7 +294,7 @@ namespace ET
 	[Message(InnerMessage.ObjectRemoveResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectRemoveResponse: ProtoObject, IActorResponse
+	public partial class ObjectRemoveResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -314,7 +314,7 @@ namespace ET
 	[Message(InnerMessage.ObjectGetRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectGetRequest: ProtoObject, IActorRequest
+	public partial class ObjectGetRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -333,7 +333,7 @@ namespace ET
 	[Message(InnerMessage.ObjectGetResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectGetResponse: ProtoObject, IActorResponse
+	public partial class ObjectGetResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -361,7 +361,7 @@ namespace ET
 	[Message(InnerMessage.R2G_GetLoginKey)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class R2G_GetLoginKey: ProtoObject, IActorRequest
+	public partial class R2G_GetLoginKey: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -376,7 +376,7 @@ namespace ET
 	[Message(InnerMessage.G2R_GetLoginKey)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2R_GetLoginKey: ProtoObject, IActorResponse
+	public partial class G2R_GetLoginKey: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -403,7 +403,7 @@ namespace ET
 	[Message(InnerMessage.G2M_SessionDisconnect)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2M_SessionDisconnect: ProtoObject, IActorLocationMessage
+	public partial class G2M_SessionDisconnect: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -414,7 +414,7 @@ namespace ET
 	[Message(InnerMessage.ObjectQueryResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectQueryResponse: ProtoObject, IActorResponse
+	public partial class ObjectQueryResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -438,7 +438,7 @@ namespace ET
 	[Message(InnerMessage.M2M_UnitTransferRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2M_UnitTransferRequest: ProtoObject, IActorRequest
+	public partial class M2M_UnitTransferRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -461,7 +461,7 @@ namespace ET
 	[Message(InnerMessage.M2M_UnitTransferResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2M_UnitTransferResponse: ProtoObject, IActorResponse
+	public partial class M2M_UnitTransferResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]

+ 36 - 36
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/OuterMessage_C_10001.cs

@@ -7,7 +7,7 @@ namespace ET
 	[Message(OuterMessage.HttpGetRouterResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class HttpGetRouterResponse: ProtoObject
+	public partial class HttpGetRouterResponse: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -22,7 +22,7 @@ namespace ET
 	[Message(OuterMessage.RouterSync)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class RouterSync: ProtoObject
+	public partial class RouterSync: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -38,7 +38,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRequest: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRequest: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -53,7 +53,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestResponse: ProtoObject, IActorResponse
+	public partial class M2C_TestResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -77,7 +77,7 @@ namespace ET
 	[Message(OuterMessage.Actor_TransferRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class Actor_TransferRequest: ProtoObject, IActorLocationRequest
+	public partial class Actor_TransferRequest: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -92,7 +92,7 @@ namespace ET
 	[Message(OuterMessage.Actor_TransferResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class Actor_TransferResponse: ProtoObject, IActorLocationResponse
+	public partial class Actor_TransferResponse: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -112,7 +112,7 @@ namespace ET
 	[Message(OuterMessage.C2G_EnterMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_EnterMap: ProtoObject, IRequest
+	public partial class C2G_EnterMap: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -123,7 +123,7 @@ namespace ET
 	[Message(OuterMessage.G2C_EnterMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_EnterMap: ProtoObject, IResponse
+	public partial class G2C_EnterMap: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -147,7 +147,7 @@ namespace ET
 	[Message(OuterMessage.MoveInfo)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class MoveInfo: ProtoObject
+	public partial class MoveInfo: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -166,7 +166,7 @@ namespace ET
 	[Message(OuterMessage.UnitInfo)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class UnitInfo: ProtoObject
+	public partial class UnitInfo: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -201,7 +201,7 @@ namespace ET
 	[Message(OuterMessage.M2C_CreateUnits)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
+	public partial class M2C_CreateUnits: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -212,7 +212,7 @@ namespace ET
 	[Message(OuterMessage.M2C_CreateMyUnit)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_CreateMyUnit: ProtoObject, IActorMessage
+	public partial class M2C_CreateMyUnit: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -223,7 +223,7 @@ namespace ET
 	[Message(OuterMessage.M2C_StartSceneChange)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_StartSceneChange: ProtoObject, IActorMessage
+	public partial class M2C_StartSceneChange: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -238,7 +238,7 @@ namespace ET
 	[Message(OuterMessage.M2C_RemoveUnits)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
+	public partial class M2C_RemoveUnits: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -249,7 +249,7 @@ namespace ET
 	[Message(OuterMessage.C2M_PathfindingResult)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_PathfindingResult: ProtoObject, IActorLocationMessage
+	public partial class C2M_PathfindingResult: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -264,7 +264,7 @@ namespace ET
 	[Message(OuterMessage.C2M_Stop)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_Stop: ProtoObject, IActorLocationMessage
+	public partial class C2M_Stop: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -275,7 +275,7 @@ namespace ET
 	[Message(OuterMessage.M2C_PathfindingResult)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_PathfindingResult: ProtoObject, IActorMessage
+	public partial class M2C_PathfindingResult: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -294,7 +294,7 @@ namespace ET
 	[Message(OuterMessage.M2C_Stop)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_Stop: ProtoObject, IActorMessage
+	public partial class M2C_Stop: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -318,7 +318,7 @@ namespace ET
 	[Message(OuterMessage.C2G_Ping)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_Ping: ProtoObject, IRequest
+	public partial class C2G_Ping: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -329,7 +329,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Ping)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Ping: ProtoObject, IResponse
+	public partial class G2C_Ping: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -352,7 +352,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Test)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Test: ProtoObject, IMessage
+	public partial class G2C_Test: MessageObject, IMessage
 	{
 	}
 
@@ -360,7 +360,7 @@ namespace ET
 	[Message(OuterMessage.C2M_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_Reload: ProtoObject, IRequest
+	public partial class C2M_Reload: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -379,7 +379,7 @@ namespace ET
 	[Message(OuterMessage.M2C_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_Reload: ProtoObject, IResponse
+	public partial class M2C_Reload: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -399,7 +399,7 @@ namespace ET
 	[Message(OuterMessage.C2R_Login)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2R_Login: ProtoObject, IRequest
+	public partial class C2R_Login: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -418,7 +418,7 @@ namespace ET
 	[Message(OuterMessage.R2C_Login)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class R2C_Login: ProtoObject, IResponse
+	public partial class R2C_Login: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -450,7 +450,7 @@ namespace ET
 	[Message(OuterMessage.C2G_LoginGate)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_LoginGate: ProtoObject, IRequest
+	public partial class C2G_LoginGate: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -469,7 +469,7 @@ namespace ET
 	[Message(OuterMessage.G2C_LoginGate)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_LoginGate: ProtoObject, IResponse
+	public partial class G2C_LoginGate: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -492,7 +492,7 @@ namespace ET
 	[Message(OuterMessage.G2C_TestHotfixMessage)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_TestHotfixMessage: ProtoObject, IMessage
+	public partial class G2C_TestHotfixMessage: MessageObject, IMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -504,7 +504,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRobotCase)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRobotCase: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRobotCase: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -519,7 +519,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestRobotCase)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestRobotCase: ProtoObject, IActorLocationResponse
+	public partial class M2C_TestRobotCase: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -542,7 +542,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRobotCase2)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRobotCase2: ProtoObject, IActorLocationMessage
+	public partial class C2M_TestRobotCase2: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -557,7 +557,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestRobotCase2)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestRobotCase2: ProtoObject, IActorLocationMessage
+	public partial class M2C_TestRobotCase2: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -573,7 +573,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TransferMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TransferMap: ProtoObject, IActorLocationRequest
+	public partial class C2M_TransferMap: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -584,7 +584,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TransferMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TransferMap: ProtoObject, IActorLocationResponse
+	public partial class M2C_TransferMap: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -604,7 +604,7 @@ namespace ET
 	[Message(OuterMessage.C2G_Benchmark)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_Benchmark: ProtoObject, IRequest
+	public partial class C2G_Benchmark: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -615,7 +615,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Benchmark)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Benchmark: ProtoObject, IResponse
+	public partial class G2C_Benchmark: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]

+ 23 - 23
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/InnerMessage_S_20001.cs

@@ -9,7 +9,7 @@ namespace ET
 	[Message(InnerMessage.ObjectQueryRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectQueryRequest: ProtoObject, IActorRequest
+	public partial class ObjectQueryRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -29,7 +29,7 @@ namespace ET
 	[Message(InnerMessage.M2A_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2A_Reload: ProtoObject, IActorRequest
+	public partial class M2A_Reload: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -40,7 +40,7 @@ namespace ET
 	[Message(InnerMessage.A2M_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class A2M_Reload: ProtoObject, IActorResponse
+	public partial class A2M_Reload: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -60,7 +60,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockRequest: ProtoObject, IActorRequest
+	public partial class G2G_LockRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -79,7 +79,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockResponse: ProtoObject, IActorResponse
+	public partial class G2G_LockResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -99,7 +99,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockReleaseRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockReleaseRequest: ProtoObject, IActorRequest
+	public partial class G2G_LockReleaseRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -118,7 +118,7 @@ namespace ET
 	[Message(InnerMessage.G2G_LockReleaseResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2G_LockReleaseResponse: ProtoObject, IActorResponse
+	public partial class G2G_LockReleaseResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -138,7 +138,7 @@ namespace ET
 	[Message(InnerMessage.ObjectAddRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectAddRequest: ProtoObject, IActorRequest
+	public partial class ObjectAddRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -161,7 +161,7 @@ namespace ET
 	[Message(InnerMessage.ObjectAddResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectAddResponse: ProtoObject, IActorResponse
+	public partial class ObjectAddResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -181,7 +181,7 @@ namespace ET
 	[Message(InnerMessage.ObjectLockRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectLockRequest: ProtoObject, IActorRequest
+	public partial class ObjectLockRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -208,7 +208,7 @@ namespace ET
 	[Message(InnerMessage.ObjectLockResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectLockResponse: ProtoObject, IActorResponse
+	public partial class ObjectLockResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -228,7 +228,7 @@ namespace ET
 	[Message(InnerMessage.ObjectUnLockRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectUnLockRequest: ProtoObject, IActorRequest
+	public partial class ObjectUnLockRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -255,7 +255,7 @@ namespace ET
 	[Message(InnerMessage.ObjectUnLockResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectUnLockResponse: ProtoObject, IActorResponse
+	public partial class ObjectUnLockResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -275,7 +275,7 @@ namespace ET
 	[Message(InnerMessage.ObjectRemoveRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectRemoveRequest: ProtoObject, IActorRequest
+	public partial class ObjectRemoveRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -294,7 +294,7 @@ namespace ET
 	[Message(InnerMessage.ObjectRemoveResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectRemoveResponse: ProtoObject, IActorResponse
+	public partial class ObjectRemoveResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -314,7 +314,7 @@ namespace ET
 	[Message(InnerMessage.ObjectGetRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectGetRequest: ProtoObject, IActorRequest
+	public partial class ObjectGetRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -333,7 +333,7 @@ namespace ET
 	[Message(InnerMessage.ObjectGetResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectGetResponse: ProtoObject, IActorResponse
+	public partial class ObjectGetResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -361,7 +361,7 @@ namespace ET
 	[Message(InnerMessage.R2G_GetLoginKey)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class R2G_GetLoginKey: ProtoObject, IActorRequest
+	public partial class R2G_GetLoginKey: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -376,7 +376,7 @@ namespace ET
 	[Message(InnerMessage.G2R_GetLoginKey)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2R_GetLoginKey: ProtoObject, IActorResponse
+	public partial class G2R_GetLoginKey: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -403,7 +403,7 @@ namespace ET
 	[Message(InnerMessage.G2M_SessionDisconnect)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2M_SessionDisconnect: ProtoObject, IActorLocationMessage
+	public partial class G2M_SessionDisconnect: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -414,7 +414,7 @@ namespace ET
 	[Message(InnerMessage.ObjectQueryResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class ObjectQueryResponse: ProtoObject, IActorResponse
+	public partial class ObjectQueryResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -438,7 +438,7 @@ namespace ET
 	[Message(InnerMessage.M2M_UnitTransferRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2M_UnitTransferRequest: ProtoObject, IActorRequest
+	public partial class M2M_UnitTransferRequest: MessageObject, IActorRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -461,7 +461,7 @@ namespace ET
 	[Message(InnerMessage.M2M_UnitTransferResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2M_UnitTransferResponse: ProtoObject, IActorResponse
+	public partial class M2M_UnitTransferResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]

+ 36 - 36
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/OuterMessage_C_10001.cs

@@ -7,7 +7,7 @@ namespace ET
 	[Message(OuterMessage.HttpGetRouterResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class HttpGetRouterResponse: ProtoObject
+	public partial class HttpGetRouterResponse: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -22,7 +22,7 @@ namespace ET
 	[Message(OuterMessage.RouterSync)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class RouterSync: ProtoObject
+	public partial class RouterSync: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -38,7 +38,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRequest: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRequest: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -53,7 +53,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestResponse: ProtoObject, IActorResponse
+	public partial class M2C_TestResponse: MessageObject, IActorResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -77,7 +77,7 @@ namespace ET
 	[Message(OuterMessage.Actor_TransferRequest)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class Actor_TransferRequest: ProtoObject, IActorLocationRequest
+	public partial class Actor_TransferRequest: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -92,7 +92,7 @@ namespace ET
 	[Message(OuterMessage.Actor_TransferResponse)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class Actor_TransferResponse: ProtoObject, IActorLocationResponse
+	public partial class Actor_TransferResponse: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -112,7 +112,7 @@ namespace ET
 	[Message(OuterMessage.C2G_EnterMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_EnterMap: ProtoObject, IRequest
+	public partial class C2G_EnterMap: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -123,7 +123,7 @@ namespace ET
 	[Message(OuterMessage.G2C_EnterMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_EnterMap: ProtoObject, IResponse
+	public partial class G2C_EnterMap: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -147,7 +147,7 @@ namespace ET
 	[Message(OuterMessage.MoveInfo)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class MoveInfo: ProtoObject
+	public partial class MoveInfo: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -166,7 +166,7 @@ namespace ET
 	[Message(OuterMessage.UnitInfo)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class UnitInfo: ProtoObject
+	public partial class UnitInfo: MessageObject
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -201,7 +201,7 @@ namespace ET
 	[Message(OuterMessage.M2C_CreateUnits)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_CreateUnits: ProtoObject, IActorMessage
+	public partial class M2C_CreateUnits: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -212,7 +212,7 @@ namespace ET
 	[Message(OuterMessage.M2C_CreateMyUnit)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_CreateMyUnit: ProtoObject, IActorMessage
+	public partial class M2C_CreateMyUnit: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -223,7 +223,7 @@ namespace ET
 	[Message(OuterMessage.M2C_StartSceneChange)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_StartSceneChange: ProtoObject, IActorMessage
+	public partial class M2C_StartSceneChange: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -238,7 +238,7 @@ namespace ET
 	[Message(OuterMessage.M2C_RemoveUnits)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_RemoveUnits: ProtoObject, IActorMessage
+	public partial class M2C_RemoveUnits: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -249,7 +249,7 @@ namespace ET
 	[Message(OuterMessage.C2M_PathfindingResult)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_PathfindingResult: ProtoObject, IActorLocationMessage
+	public partial class C2M_PathfindingResult: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -264,7 +264,7 @@ namespace ET
 	[Message(OuterMessage.C2M_Stop)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_Stop: ProtoObject, IActorLocationMessage
+	public partial class C2M_Stop: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -275,7 +275,7 @@ namespace ET
 	[Message(OuterMessage.M2C_PathfindingResult)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_PathfindingResult: ProtoObject, IActorMessage
+	public partial class M2C_PathfindingResult: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -294,7 +294,7 @@ namespace ET
 	[Message(OuterMessage.M2C_Stop)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_Stop: ProtoObject, IActorMessage
+	public partial class M2C_Stop: MessageObject, IActorMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -318,7 +318,7 @@ namespace ET
 	[Message(OuterMessage.C2G_Ping)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_Ping: ProtoObject, IRequest
+	public partial class C2G_Ping: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -329,7 +329,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Ping)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Ping: ProtoObject, IResponse
+	public partial class G2C_Ping: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -352,7 +352,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Test)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Test: ProtoObject, IMessage
+	public partial class G2C_Test: MessageObject, IMessage
 	{
 	}
 
@@ -360,7 +360,7 @@ namespace ET
 	[Message(OuterMessage.C2M_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_Reload: ProtoObject, IRequest
+	public partial class C2M_Reload: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -379,7 +379,7 @@ namespace ET
 	[Message(OuterMessage.M2C_Reload)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_Reload: ProtoObject, IResponse
+	public partial class M2C_Reload: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -399,7 +399,7 @@ namespace ET
 	[Message(OuterMessage.C2R_Login)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2R_Login: ProtoObject, IRequest
+	public partial class C2R_Login: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -418,7 +418,7 @@ namespace ET
 	[Message(OuterMessage.R2C_Login)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class R2C_Login: ProtoObject, IResponse
+	public partial class R2C_Login: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -450,7 +450,7 @@ namespace ET
 	[Message(OuterMessage.C2G_LoginGate)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_LoginGate: ProtoObject, IRequest
+	public partial class C2G_LoginGate: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -469,7 +469,7 @@ namespace ET
 	[Message(OuterMessage.G2C_LoginGate)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_LoginGate: ProtoObject, IResponse
+	public partial class G2C_LoginGate: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -492,7 +492,7 @@ namespace ET
 	[Message(OuterMessage.G2C_TestHotfixMessage)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_TestHotfixMessage: ProtoObject, IMessage
+	public partial class G2C_TestHotfixMessage: MessageObject, IMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -504,7 +504,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRobotCase)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRobotCase: ProtoObject, IActorLocationRequest
+	public partial class C2M_TestRobotCase: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -519,7 +519,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestRobotCase)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestRobotCase: ProtoObject, IActorLocationResponse
+	public partial class M2C_TestRobotCase: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -542,7 +542,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TestRobotCase2)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TestRobotCase2: ProtoObject, IActorLocationMessage
+	public partial class C2M_TestRobotCase2: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -557,7 +557,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TestRobotCase2)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TestRobotCase2: ProtoObject, IActorLocationMessage
+	public partial class M2C_TestRobotCase2: MessageObject, IActorLocationMessage
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -573,7 +573,7 @@ namespace ET
 	[Message(OuterMessage.C2M_TransferMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2M_TransferMap: ProtoObject, IActorLocationRequest
+	public partial class C2M_TransferMap: MessageObject, IActorLocationRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -584,7 +584,7 @@ namespace ET
 	[Message(OuterMessage.M2C_TransferMap)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class M2C_TransferMap: ProtoObject, IActorLocationResponse
+	public partial class M2C_TransferMap: MessageObject, IActorLocationResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -604,7 +604,7 @@ namespace ET
 	[Message(OuterMessage.C2G_Benchmark)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class C2G_Benchmark: ProtoObject, IRequest
+	public partial class C2G_Benchmark: MessageObject, IRequest
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]
@@ -615,7 +615,7 @@ namespace ET
 	[Message(OuterMessage.G2C_Benchmark)]
 	[ProtoContract]
 	[MemoryPackable]
-	public partial class G2C_Benchmark: ProtoObject, IResponse
+	public partial class G2C_Benchmark: MessageObject, IResponse
 	{
 		[ProtoMember(1)]
 		[MemoryPackOrder(0)]

+ 2 - 0
Unity/Assets/Scripts/Codes/Model/Share/Module/Message/OpcodeHelper.cs

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.Diagnostics;
 
 namespace ET
 {
@@ -34,6 +35,7 @@ namespace ET
             return opcode >= OpcodeRangeDefine.InnerMinOpcode;
         }
 
+        [Conditional("CLOSE")]
         public static void LogMsg(int zone, object message)
         {
             ushort opcode = NetServices.Instance.GetOpcode(message.GetType());

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Message/Session.cs

@@ -126,7 +126,7 @@ namespace ET
         {
             self.LastSendTime = TimeHelper.ClientNow();
             OpcodeHelper.LogMsg(self.DomainZone(), message);
-            NetServices.Instance.SendMessage(self.ServiceId, self.Id, actorId, message);
+            NetServices.Instance.SendMessage(self.ServiceId, self.Id, actorId, message as MessageObject);
         }
     }
 

+ 21 - 23
Unity/Assets/Scripts/Core/Module/Network/AService.cs

@@ -10,41 +10,39 @@ namespace ET
         
         public ServiceType ServiceType { get; protected set; }
         
-        private (object Message, MemoryBuffer MemoryStream) lastMessageInfo;
+        private (MessageObject Message, MemoryBuffer MemoryStream) lastMessageInfo;
         
         // 缓存上一个发送的消息,这样广播消息的时候省掉多次序列化,这样有个另外的问题,客户端就不能保存发送的消息来减少gc
-        public MemoryBuffer Fetch(object message)
+        // 需要广播的消息不能用对象池,因为用了对象池无法使用ReferenceEquals去判断是否是同一个消息,服务端gc很强,这种消息不用池问题不大
+        public MemoryBuffer Fetch(MessageObject message)
         {
-            if (object.ReferenceEquals(lastMessageInfo.Message, message))
+            MemoryBuffer stream;
+            if (!message.IsFromPool) // 不是从池中来的消息, 服务端需要广播的消息不能用对象池
             {
-                Log.Debug($"message serialize cache: {message.GetType().Name}");
-                return lastMessageInfo.MemoryStream;
+                if (ReferenceEquals(message, this.lastMessageInfo.Message))
+                {
+                    Log.Debug($"message serialize cache: {message.GetType().Name}");
+                    return lastMessageInfo.MemoryStream;
+                }
+                stream = new MemoryBuffer(); // 因为广播,可能MemoryBuffer会用多次,所以不能用对象池
+                MessageSerializeHelper.MessageToStream(stream, message);
+                this.lastMessageInfo = (message, stream);
+            }
+            else
+            {
+                stream = NetServices.Instance.Fetch();
+                MessageSerializeHelper.MessageToStream(stream, message);
             }
-
-            MemoryBuffer stream = NetServices.Instance.Fetch();
-            MessageSerializeHelper.MessageToStream(stream, message);
-            this.lastMessageInfo = (message, stream);
             return stream;
         }
-
-        private MemoryBuffer lastRecyleMessage;
         
-        // Recycle不能直接回到池中,因为有可能广播消息的时候,发送的是同一个MemoryBuff
         public void Recycle(MemoryBuffer memoryStream)
         {
-            if (this.lastRecyleMessage == null)
-            {
-                this.lastRecyleMessage = memoryStream;
-                return;
-            }
-
-            if (ReferenceEquals(this.lastRecyleMessage, memoryStream))
+            if (!memoryStream.IsFromPool)
             {
                 return;
             }
-            
-            NetServices.Instance.Recycle(this.lastRecyleMessage);
-            this.lastRecyleMessage = memoryStream;
+            NetServices.Instance.Recycle(memoryStream);
         }
         
         public virtual void Dispose()
@@ -59,7 +57,7 @@ namespace ET
 
         public abstract void Create(long id, IPEndPoint address);
 
-        public abstract void Send(long channelId, long actorId, object message);
+        public abstract void Send(long channelId, long actorId, MessageObject message);
 
         public virtual (uint, uint) GetChannelConn(long channelId)
         {

+ 14 - 5
Unity/Assets/Scripts/Core/Module/Network/KChannel.cs

@@ -174,6 +174,8 @@ namespace ET
 			}
 		}
 
+		private long lastConnectTime = long.MaxValue;
+
 		/// <summary>
 		/// 发送请求连接消息
 		/// </summary>
@@ -185,6 +187,13 @@ namespace ET
 				{
 					return;
 				}
+
+				// 300毫秒后再次update发送connect请求
+				if (timeNow < this.lastConnectTime + 300)
+				{
+					this.Service.AddToUpdate(0, this.Id);
+					return;
+				}
 				
 				// 10秒连接超时
 				if (timeNow > this.CreateTime + KService.ConnectTimeoutTime)
@@ -200,9 +209,10 @@ namespace ET
 				buffer.WriteTo(5, this.RemoteConn);
 				this.socket.SendTo(buffer, 0, 9, SocketFlags.None, this.RemoteAddress);
 				Log.Info($"kchannel connect {this.LocalConn} {this.RemoteConn} {this.RealAddress} {this.socket.LocalEndPoint}");
-				
-				// 300毫秒后再次update发送connect请求
-				this.Service.AddToUpdate(timeNow + 300, this.Id);
+
+				this.lastConnectTime = timeNow;
+
+				this.Service.AddToUpdate(0, this.Id);
 			}
 			catch (Exception e)
 			{
@@ -437,10 +447,9 @@ namespace ET
 			this.Service.Recycle(memoryStream);
 		}
 		
-		public void Send(long actorId, object message)
+		public void Send(long actorId, MessageObject message)
 		{
 			MemoryBuffer stream = this.Service.Fetch(message);
-			MessageSerializeHelper.MessageToStream(stream, message);
 			KcpWaitPacket kcpWaitPacket = new() { ActorId = actorId, MemoryStream = stream };
 			if (!this.IsConnected)
 			{

+ 13 - 4
Unity/Assets/Scripts/Core/Module/Network/KService.cs

@@ -149,11 +149,13 @@ namespace ET
         // 下帧要更新的channel
         private readonly HashSet<long> updateIds = new HashSet<long>();
         
+#if !UNITY
         // 下次时间更新的channel
-        private readonly MultiMap<long, long> timeId = new MultiMap<long, long>();
+        private readonly MultiMap<long, long> timeId = new();
         private readonly List<long> timeOutTime = new List<long>();
         // 记录最小时间,不用每次都去MultiMap取第一个值
         private long minTime;
+#endif
         
         public override bool IsDispose()
         {
@@ -519,7 +521,7 @@ namespace ET
             Log.Info($"channel send fin: {localConn} {remoteConn} {address} {error}");
         }
         
-        public override void Send(long channelId, long actorId, object message)
+        public override void Send(long channelId, long actorId, MessageObject message)
         {
             KChannel channel = this.Get(channelId);
             if (channel == null)
@@ -533,9 +535,9 @@ namespace ET
         public override void Update()
         {
             uint timeNow = this.TimeNow;
-            
+
             this.TimerOut(timeNow);
-            
+
             this.CheckWaitAcceptChannel(timeNow);
             
             this.Recv();
@@ -597,6 +599,7 @@ namespace ET
         // 服务端需要看channel的update时间是否已到
         public void AddToUpdate(long time, long id)
         {
+#if !UNITY
             if (time == 0)
             {
                 this.updateIds.Add(id);
@@ -607,11 +610,16 @@ namespace ET
                 this.minTime = time;
             }
             this.timeId.Add(time, id);
+#else
+            this.updateIds.Add(id);
+#endif
         }
         
+
         // 计算到期需要update的channel
         private void TimerOut(uint timeNow)
         {
+#if !UNITY
             if (this.timeId.Count == 0)
             {
                 return;
@@ -645,6 +653,7 @@ namespace ET
                 }
                 this.timeId.Remove(k);
             }
+#endif
         }
     }
 }

+ 65 - 0
Unity/Assets/Scripts/Core/Module/Network/MessagePool.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+
+namespace ET
+{
+    public class MessagePool
+    {
+        private readonly Dictionary<Type, Queue<MessageObject>> pool = new();
+        
+        public T Fetch<T>() where T: MessageObject
+        {
+            return this.Fetch(typeof (T)) as T;
+        }
+
+        public MessageObject Fetch(Type type)
+        {
+            lock (this.pool)
+            {
+                MessageObject messageObject;
+                Queue<MessageObject> queue = null;
+                if (!pool.TryGetValue(type, out queue))
+                {
+                    messageObject = Activator.CreateInstance(type) as MessageObject;
+                }
+                else if (queue.Count == 0)
+                {
+                    messageObject = Activator.CreateInstance(type) as MessageObject;
+                }
+                else
+                {
+                    messageObject = queue.Dequeue();
+                }
+                
+                messageObject.IsFromPool = true;
+                return messageObject;
+            }
+        }
+
+        public void Recycle(MessageObject obj)
+        {
+            if (!obj.IsFromPool)
+            {
+                return;
+            }
+            Type type = obj.GetType();
+            
+            lock (this.pool)
+            {
+                Queue<MessageObject> queue = null;
+                if (!pool.TryGetValue(type, out queue))
+                {
+                    queue = new Queue<MessageObject>();
+                    pool.Add(type, queue);
+                }
+
+                // 一种对象最大为100个
+                if (queue.Count > 100)
+                {
+                    return;
+                }
+                queue.Enqueue(obj);
+            }
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Core/Module/Network/MessagePool.cs.meta

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

+ 33 - 7
Unity/Assets/Scripts/Core/Module/Network/NetServices.cs

@@ -86,8 +86,10 @@ namespace ET
 
         #region 线程安全
 
+        private readonly MessagePool messagePool = new();
+
         // 初始化后不变,所以主线程,网络线程都可以读
-        private readonly DoubleMap<Type, ushort> typeOpcode = new DoubleMap<Type, ushort>();
+        private readonly DoubleMap<Type, ushort> typeOpcode = new();
 
         public ushort GetOpcode(Type type)
         {
@@ -99,6 +101,25 @@ namespace ET
             return this.typeOpcode.GetKeyByValue(opcode);
         }
 
+        public MessageObject FetchMessage(Type type)
+        {
+            return this.messagePool.Fetch(type);
+        }
+        
+        public T FetchMessage<T>() where T: MessageObject
+        {
+            return this.messagePool.Fetch<T>();
+        }
+
+        public void RecycleMessage(MessageObject obj)
+        {
+            if (obj == null)
+            {
+                return;
+            }
+            this.messagePool.Recycle(obj);
+        }
+
         #endregion
 
         #region 主线程
@@ -142,7 +163,7 @@ namespace ET
             ToNetThread(ref netOperator);
         }
 
-        public void SendMessage(int serviceId, long channelId, long actorId, object message)
+        public void SendMessage(int serviceId, long channelId, long actorId, MessageObject message)
         {
             NetOperator netOperator = new NetOperator()
             {
@@ -261,10 +282,10 @@ namespace ET
 
         #region 网络线程
 
-        private readonly Dictionary<int, AService> services = new Dictionary<int, AService>();
-        private readonly Queue<int> queue = new Queue<int>();
+        private readonly Dictionary<int, AService> services = new();
+        private readonly Queue<int> queue = new();
 
-        private readonly Queue<MemoryBuffer> pool = new Queue<MemoryBuffer>();
+        private readonly Queue<MemoryBuffer> pool = new();
 
         public MemoryBuffer Fetch()
         {
@@ -273,11 +294,16 @@ namespace ET
                 return this.pool.Dequeue();
             }
 
-            return new MemoryBuffer();
+            MemoryBuffer memoryBuffer = new() { IsFromPool = true };
+            return memoryBuffer;
         }
 
         public void Recycle(MemoryBuffer memoryBuffer)
         {
+            if (!memoryBuffer.IsFromPool)
+            {
+                return;
+            }
             if (memoryBuffer.Capacity > 128) // 太大的不回收,GC
             {
                 return;
@@ -374,7 +400,7 @@ namespace ET
                         AService service = this.Get(op.ServiceId);
                         if (service != null)
                         {
-                            service.Send(op.ChannelId, op.ActorId, op.Object);
+                            service.Send(op.ChannelId, op.ActorId, op.Object as MessageObject);
                         }
 
                         break;

+ 3 - 1
Unity/Assets/Scripts/Core/Module/Network/TChannel.cs

@@ -90,12 +90,14 @@ namespace ET
 			this.socket = null;
 		}
 
-		public void Send(long actorId, MemoryBuffer stream)
+		public void Send(long actorId, MessageObject message)
 		{
 			if (this.IsDisposed)
 			{
 				throw new Exception("TChannel已经被Dispose, 不能发送消息");
 			}
+			
+			MemoryBuffer stream = this.Service.Fetch(message);
 
 			switch (this.Service.ServiceType)
 			{

+ 3 - 3
Unity/Assets/Scripts/Core/Module/Network/TService.cs

@@ -161,7 +161,7 @@ namespace ET
 			this.idChannels.Remove(id);
 		}
 
-		public override void Send(long channelId, long actorId, object message)
+		public override void Send(long channelId, long actorId, MessageObject message)
 		{
 			try
 			{
@@ -171,8 +171,8 @@ namespace ET
 					NetServices.Instance.OnError(this.Id, channelId, ErrorCore.ERR_SendMessageNotFoundTChannel);
 					return;
 				}
-				MemoryBuffer memoryStream = this.Fetch(message);
-				aChannel.Send(actorId, memoryStream);
+				
+				aChannel.Send(actorId, message);
 			}
 			catch (Exception e)
 			{

+ 11 - 6
Unity/Assets/Scripts/Core/Module/Network/WChannel.cs

@@ -14,7 +14,7 @@ namespace ET
 
         private readonly WebSocket webSocket;
 
-        private readonly Queue<MemoryStream> queue = new Queue<MemoryStream>();
+        private readonly Queue<MemoryBuffer> queue = new();
 
         private bool isSending;
 
@@ -86,8 +86,10 @@ namespace ET
             }
         }
 
-        public void Send(MemoryStream stream)
+        public void Send(MessageObject message)
         {
+            MemoryBuffer stream = this.Service.Fetch(message);
+            
             switch (this.Service.ServiceType)
             {
                 case ServiceType.Inner:
@@ -105,7 +107,7 @@ namespace ET
             }
         }
 
-        public async ETTask StartSend()
+        private async ETTask StartSend()
         {
             if (this.IsDisposed)
             {
@@ -129,10 +131,13 @@ namespace ET
                         return;
                     }
 
-                    MemoryStream bytes = this.queue.Dequeue();
+                    MemoryBuffer bytes = this.queue.Dequeue();
                     try
                     {
-                        await this.webSocket.SendAsync(new ReadOnlyMemory<byte>(bytes.GetBuffer(), (int)bytes.Position, (int)(bytes.Length - bytes.Position)), WebSocketMessageType.Binary, true, cancellationTokenSource.Token);
+                        await this.webSocket.SendAsync(bytes.GetMemory(), WebSocketMessageType.Binary, true, cancellationTokenSource.Token);
+                        
+                        this.Service.Recycle(bytes);
+                        
                         if (this.IsDisposed)
                         {
                             return;
@@ -152,7 +157,7 @@ namespace ET
             }
         }
 
-        private byte[] cache = new byte[ushort.MaxValue];
+        private readonly byte[] cache = new byte[ushort.MaxValue];
 
         public async ETTask StartRecv()
         {

+ 2 - 3
Unity/Assets/Scripts/Core/Module/Network/WService.cs

@@ -133,15 +133,14 @@ namespace ET
             throw new NotImplementedException();
         }
 
-        public override void Send(long channelId, long actorId, object message)
+        public override void Send(long channelId, long actorId, MessageObject message)
         {
             this.channels.TryGetValue(channelId, out WChannel channel);
             if (channel == null)
             {
                 return;
             }
-            MemoryStream memoryStream = this.Fetch(message);
-            channel.Send(memoryStream);
+            channel.Send(message);
         }
 
         public override void Update()

+ 1 - 1
Unity/Assets/Scripts/Core/Module/ObjectPool/ObjectPool.cs

@@ -5,7 +5,7 @@ namespace ET
 {
     public class ObjectPool: Singleton<ObjectPool>
     {
-        private readonly Dictionary<Type, Queue<object>> pool = new Dictionary<Type, Queue<object>>();
+        private readonly Dictionary<Type, Queue<object>> pool = new();
         
         public T Fetch<T>() where T: class
         {

+ 1 - 1
Unity/Assets/Scripts/Core/Module/Timer/TimerComponent.cs

@@ -58,7 +58,7 @@ namespace ET
         /// <summary>
         /// key: time, value: timer id
         /// </summary>
-        private readonly MultiMap<long, long> TimeId = new();
+        private readonly MultiMap<long, long> TimeId = new(1000);
 
         private readonly Queue<long> timeOutTime = new();
 

+ 45 - 2
Unity/Assets/Scripts/Core/MultiMap.cs

@@ -5,7 +5,38 @@ namespace ET
 {
     public class MultiMap<T, K>: SortedDictionary<T, List<K>>
     {
-        private readonly List<K> Empty = new List<K>();
+        private readonly List<K> Empty = new();
+        private readonly int maxPoolCount;
+        private readonly Queue<List<K>> pool;
+
+        public MultiMap(int maxPoolCount = 0)
+        {
+            this.maxPoolCount = maxPoolCount;
+            this.pool = new Queue<List<K>>(maxPoolCount);
+        }
+
+        private List<K> FetchList()
+        {
+            if (this.pool.Count > 0)
+            {
+                return this.pool.Dequeue();
+            }
+            return new List<K>(10);
+        }
+
+        private void Recycle(List<K> list)
+        {
+            if (list == null)
+            {
+                return;
+            }
+            if (this.pool.Count == this.maxPoolCount)
+            {
+                return;
+            }
+            list.Clear();
+            this.pool.Enqueue(list);
+        }
 
         public void Add(T t, K k)
         {
@@ -13,7 +44,7 @@ namespace ET
             this.TryGetValue(t, out list);
             if (list == null)
             {
-                list = new List<K>();
+                list = this.FetchList();
                 this.Add(t, list);
             }
             list.Add(k);
@@ -38,6 +69,18 @@ namespace ET
             return true;
         }
 
+        public new bool Remove(T t)
+        {
+            List<K> list;
+            this.TryGetValue(t, out list);
+            if (list == null)
+            {
+                return false;
+            }
+            this.Recycle(list);
+            return base.Remove(t);
+        }
+
         /// <summary>
         /// 不返回内部的list,copy一份出来
         /// </summary>

+ 10 - 0
Unity/Assets/Scripts/Core/Object/MessageObject.cs

@@ -0,0 +1,10 @@
+using System;
+using System.ComponentModel;
+
+namespace ET
+{
+    public abstract class MessageObject: ProtoObject
+    {
+        public bool IsFromPool;
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Core/Object/MessageObject.cs.meta

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

+ 7 - 6
Unity/Assets/Scripts/Core/Serialize/MemoryBuffer.cs

@@ -7,7 +7,8 @@ namespace ET
 {
     public class MemoryBuffer: MemoryStream, IBufferWriter<byte>
     {
-        private int _origin;
+        private int origin;
+        public bool IsFromPool;
         
         public MemoryBuffer()
         {
@@ -23,7 +24,7 @@ namespace ET
         
         public MemoryBuffer(byte[] buffer, int index, int length): base(buffer, index, length)
         {
-            _origin = index;
+            this.origin = index;
         }
 
         protected override void Dispose(bool disposing)
@@ -31,9 +32,9 @@ namespace ET
             this.Seek(0, SeekOrigin.Begin);
         }
         
-        public ReadOnlyMemory<byte> WrittenMemory => this.GetBuffer().AsMemory(_origin, (int)this.Position);
+        public ReadOnlyMemory<byte> WrittenMemory => this.GetBuffer().AsMemory(this.origin, (int)this.Position);
 
-        public ReadOnlySpan<byte> WrittenSpan => this.GetBuffer().AsSpan(_origin, (int)this.Position);
+        public ReadOnlySpan<byte> WrittenSpan => this.GetBuffer().AsSpan(this.origin, (int)this.Position);
 
         public void Advance(int count)
         {
@@ -51,7 +52,7 @@ namespace ET
             {
                 this.SetLength(this.Position + sizeHint);
             }
-            var memory = this.GetBuffer().AsMemory((int)this.Position + _origin, (int)(this.Length - this.Position));
+            var memory = this.GetBuffer().AsMemory((int)this.Position + this.origin, (int)(this.Length - this.Position));
             return memory;
         }
 
@@ -61,7 +62,7 @@ namespace ET
             {
                 this.SetLength(this.Position + sizeHint);
             }
-            var span = this.GetBuffer().AsSpan((int)this.Position + _origin, (int)(this.Length - this.Position));
+            var span = this.GetBuffer().AsSpan((int)this.Position + this.origin, (int)(this.Length - this.Position));
             return span;
         }
     }

+ 26 - 6
Unity/Assets/Scripts/Core/Serialize/MemoryPackHelper.cs

@@ -25,6 +25,16 @@ namespace ET
         public static void Init()
         {
         }
+
+        public static byte[] Serialize(object message)
+        {
+            return MemoryPackSerializer.Serialize(message.GetType(), message);
+        }
+
+        public static void Serialize(object message, MemoryBuffer stream)
+        {
+            MemoryPackSerializer.Serialize(message.GetType(), stream, message);
+        }
         
         public static object Deserialize(Type type, byte[] bytes, int index, int count)
         {
@@ -36,19 +46,29 @@ namespace ET
             return o;
         }
 
-        public static byte[] Serialize(object message)
+        public static object Deserialize(Type type, byte[] bytes, int index, int count, ref object o)
         {
-            return MemoryPackSerializer.Serialize(message.GetType(), message);
+            MemoryPackSerializer.Deserialize(type, bytes.AsSpan(index, count), ref o);
+            if (o is ISupportInitialize supportInitialize)
+            {
+                supportInitialize.EndInit();
+            }
+            return o;
         }
 
-        public static void Serialize(object message, MemoryBuffer stream)
+        public static object Deserialize(Type type, MemoryBuffer stream)
         {
-            MemoryPackSerializer.Serialize(message.GetType(), stream, message);
+            object o = MemoryPackSerializer.Deserialize(type, stream.GetSpan());
+            if (o is ISupportInitialize supportInitialize)
+            {
+                supportInitialize.EndInit();
+            }
+            return o;
         }
 
-        public static object Deserialize(Type type, MemoryBuffer stream)
+        public static object Deserialize(Type type, MemoryBuffer stream, ref object o)
         {
-            object o = MemoryPackSerializer.Deserialize(type, stream.GetSpan());
+            MemoryPackSerializer.Deserialize(type, stream.GetSpan(), ref o);
             if (o is ISupportInitialize supportInitialize)
             {
                 supportInitialize.EndInit();

+ 19 - 15
Unity/Assets/Scripts/Core/Serialize/SerializeHelper.cs

@@ -9,21 +9,8 @@ namespace ET
 	{
 		// 这里不用宏控制,因为服务端也要用,如果用宏,需要同时在服务端客户端加宏,挺麻烦的,不如直接在这里改代码
 		public const bool UseMemoryPack = true;
-		
-		public static object Deserialize(Type type, byte[] bytes, int index, int count)
-		{
-			if (UseMemoryPack)
-			{
-				return MemoryPackHelper.Deserialize(type, bytes, index, count);
-			}
-			else
-			{
-				using MemoryStream memoryStream = new MemoryStream(bytes, index, count);
-				return ProtoBuf.Serializer.Deserialize(type, memoryStream);
-			}
-		}
 
-        public static byte[] Serialize(object message)
+		public static byte[] Serialize(object message)
 		{
 			if (UseMemoryPack)
 			{
@@ -46,12 +33,29 @@ namespace ET
 				ProtobufHelper.Serialize(message, stream);	
 			}
 		}
+		
+		public static object Deserialize(Type type, byte[] bytes, int index, int count)
+		{
+			if (UseMemoryPack)
+			{
+				object o = NetServices.Instance.FetchMessage(type);
+				MemoryPackHelper.Deserialize(type, bytes, index, count, ref o);
+				return o;
+			}
+			else
+			{
+				using MemoryStream memoryStream = new MemoryStream(bytes, index, count);
+				return ProtoBuf.Serializer.Deserialize(type, memoryStream);
+			}
+		}
 
 		public static object Deserialize(Type type, MemoryBuffer stream)
 		{
 			if (UseMemoryPack)
 			{
-				return MemoryPackHelper.Deserialize(type, stream);
+				object o = NetServices.Instance.FetchMessage(type);
+				MemoryPackHelper.Deserialize(type, stream, ref o);
+				return o;
 			}
 			else
 			{