Просмотр исходного кода

热更新配置只能每次更新一个配置

tanghai 4 лет назад
Родитель
Сommit
e3e06ce2a7

+ 0 - 39
Proto/OuterMessage.proto

@@ -186,42 +186,3 @@ message G2C_TestHotfixMessage // IMessage
 {
 {
 	string Info = 1;
 	string Info = 1;
 }
 }
-
-//ResponseType M2C_TestActorResponse
-message C2M_TestActorRequest // IActorLocationRequest
-{
-	int32 RpcId = 90;
-	int64 ActorId = 91;
-	string Info = 1;
-}
-
-message M2C_TestActorResponse // IActorLocationResponse
-{
-	int32 RpcId = 90;
-	int32 Error = 91;
-	string Message = 92;
-	string Info = 1;
-}
-
-message PlayerInfo // IMessage
-{
-	int32 RpcId = 90;
-}
-
-//ResponseType G2C_PlayerInfo
-message C2G_PlayerInfo // IRequest
-{
-	int32 RpcId = 90;
-}
-
-message G2C_PlayerInfo // IResponse
-{
-	int32 RpcId = 90;
-	int32 Error = 91;
-	string Message = 92;
-	PlayerInfo PlayerInfo = 1;
-	repeated PlayerInfo PlayerInfos = 2;
-    repeated string TestRepeatedString = 3;
-    repeated int32 TestRepeatedInt32 = 4;
-    repeated int64 TestRepeatedInt64 = 5;
-}

+ 2 - 1
Server/Hotfix/Demo/AppStart_Init.cs

@@ -10,7 +10,8 @@ namespace ET
         {
         {
             Game.Scene.AddComponent<ConfigComponent>();
             Game.Scene.AddComponent<ConfigComponent>();
             
             
-            ConfigComponent.GetAllConfigBytes = LoadConfigHelper.LoadAllConfigBytes;
+            ConfigComponent.GetAllConfigBytes = LoadConfigHelper.GetAllConfigBytes;
+            ConfigComponent.GetOneConfigBytes = LoadConfigHelper.GetOneConfigBytes;
             await ConfigComponent.Instance.LoadAsync();
             await ConfigComponent.Instance.LoadAsync();
 
 
             StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);
             StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);

+ 0 - 16
Server/Hotfix/Demo/C2M_TestActorRequestHandler.cs

@@ -1,16 +0,0 @@
-using System;
-
-
-namespace ET
-{
-	[ActorMessageHandler]
-	public class C2M_TestActorRequestHandler : AMActorLocationRpcHandler<Unit, C2M_TestActorRequest, M2C_TestActorResponse>
-	{
-		protected override async ETTask Run(Unit unit, C2M_TestActorRequest message, M2C_TestActorResponse response, Action reply)
-		{
-			response.Info = "actor rpc response";
-			reply();
-			await ETTask.CompletedTask;
-		}
-	}
-}

+ 0 - 27
Server/Hotfix/Handler/C2G_PlayerInfoHandler.cs

@@ -1,27 +0,0 @@
-using System;
-
-
-namespace ET
-{
-	// 用来测试消息包含复杂类型,是否产生gc
-	[MessageHandler]
-	public class C2G_PlayerInfoHandler : AMRpcHandler<C2G_PlayerInfo, G2C_PlayerInfo>
-	{
-		protected override async ETTask Run(Session session, C2G_PlayerInfo request, G2C_PlayerInfo response, Action reply)
-		{
-			response.PlayerInfo = new PlayerInfo();
-			response.PlayerInfos.Add(new PlayerInfo() {RpcId = 1});
-			response.PlayerInfos.Add(new PlayerInfo() {RpcId = 2});
-			response.PlayerInfos.Add(new PlayerInfo() {RpcId = 3});
-			response.TestRepeatedInt32.Add(4);
-			response.TestRepeatedInt32.Add(5);
-			response.TestRepeatedInt32.Add(6);
-			response.TestRepeatedInt64.Add(7);
-			response.TestRepeatedInt64.Add(8);
-			response.TestRepeatedString.Add("9");
-			response.TestRepeatedString.Add("10");
-			reply();
-			await ETTask.CompletedTask;
-		}
-	}
-}

+ 7 - 1
Server/Hotfix/Helper/LoadConfigHelper.cs

@@ -5,7 +5,7 @@ namespace ET
 {
 {
     public static class LoadConfigHelper
     public static class LoadConfigHelper
     {
     {
-        public static void LoadAllConfigBytes(Dictionary<string, byte[]> output)
+        public static void GetAllConfigBytes(Dictionary<string, byte[]> output)
         {
         {
             foreach (string file in Directory.GetFiles($"../Config", "*.bytes"))
             foreach (string file in Directory.GetFiles($"../Config", "*.bytes"))
             {
             {
@@ -13,5 +13,11 @@ namespace ET
                 output[key] = File.ReadAllBytes(file);
                 output[key] = File.ReadAllBytes(file);
             }
             }
         }
         }
+        
+        public static byte[] GetOneConfigBytes(string configName)
+        {
+            byte[] configBytes = File.ReadAllBytes($"../Config/{configName}.bytes");
+            return configBytes;
+        }
     }
     }
 }
 }

+ 0 - 83
Server/Model/Generate/Message/OuterMessage.cs

@@ -389,87 +389,4 @@ namespace ET
 
 
 	}
 	}
 
 
-	[ResponseType(typeof(M2C_TestActorResponse))]
-	[Message(OuterOpcode.C2M_TestActorRequest)]
-	[ProtoContract]
-	public partial class C2M_TestActorRequest: Object, IActorLocationRequest
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-		[ProtoMember(91)]
-		public long ActorId { get; set; }
-
-		[ProtoMember(1)]
-		public string Info { get; set; }
-
-	}
-
-	[Message(OuterOpcode.M2C_TestActorResponse)]
-	[ProtoContract]
-	public partial class M2C_TestActorResponse: Object, IActorLocationResponse
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-		[ProtoMember(91)]
-		public int Error { get; set; }
-
-		[ProtoMember(92)]
-		public string Message { get; set; }
-
-		[ProtoMember(1)]
-		public string Info { get; set; }
-
-	}
-
-	[Message(OuterOpcode.PlayerInfo)]
-	[ProtoContract]
-	public partial class PlayerInfo: Object, IMessage
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-	}
-
-	[ResponseType(typeof(G2C_PlayerInfo))]
-	[Message(OuterOpcode.C2G_PlayerInfo)]
-	[ProtoContract]
-	public partial class C2G_PlayerInfo: Object, IRequest
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-	}
-
-	[Message(OuterOpcode.G2C_PlayerInfo)]
-	[ProtoContract]
-	public partial class G2C_PlayerInfo: Object, IResponse
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-		[ProtoMember(91)]
-		public int Error { get; set; }
-
-		[ProtoMember(92)]
-		public string Message { get; set; }
-
-		[ProtoMember(1)]
-		public PlayerInfo PlayerInfo { get; set; }
-
-		[ProtoMember(2)]
-		public List<PlayerInfo> PlayerInfos = new List<PlayerInfo>();
-
-		[ProtoMember(3)]
-		public List<string> TestRepeatedString = new List<string>();
-
-		[ProtoMember(4)]
-		public List<int> TestRepeatedInt32 = new List<int>();
-
-		[ProtoMember(5)]
-		public List<long> TestRepeatedInt64 = new List<long>();
-
-	}
-
 }
 }

+ 0 - 5
Server/Model/Generate/Message/OuterOpcode.cs

@@ -24,10 +24,5 @@ namespace ET
 		 public const ushort C2G_LoginGate = 20020;
 		 public const ushort C2G_LoginGate = 20020;
 		 public const ushort G2C_LoginGate = 20021;
 		 public const ushort G2C_LoginGate = 20021;
 		 public const ushort G2C_TestHotfixMessage = 20022;
 		 public const ushort G2C_TestHotfixMessage = 20022;
-		 public const ushort C2M_TestActorRequest = 20023;
-		 public const ushort M2C_TestActorResponse = 20024;
-		 public const ushort PlayerInfo = 20025;
-		 public const ushort C2G_PlayerInfo = 20026;
-		 public const ushort G2C_PlayerInfo = 20027;
 	}
 	}
 }
 }

+ 2 - 1
Unity/Assets/HotfixView/Demo/AppStart_Init.cs

@@ -11,7 +11,8 @@ namespace ET
             Game.Scene.AddComponent<ResourcesComponent>();
             Game.Scene.AddComponent<ResourcesComponent>();
             ResourcesComponent.Instance.LoadBundle("config.unity3d");
             ResourcesComponent.Instance.LoadBundle("config.unity3d");
             Game.Scene.AddComponent<ConfigComponent>();
             Game.Scene.AddComponent<ConfigComponent>();
-            ConfigComponent.GetAllConfigBytes = LoadConfigHelper.LoadAllConfigBytes;
+            ConfigComponent.GetAllConfigBytes = LoadConfigHelper.GetAllConfigBytes;
+            ConfigComponent.GetOneConfigBytes = LoadConfigHelper.GetOneConfigBytes;
             await ConfigComponent.Instance.LoadAsync();
             await ConfigComponent.Instance.LoadAsync();
             ResourcesComponent.Instance.UnloadBundle("config.unity3d");
             ResourcesComponent.Instance.UnloadBundle("config.unity3d");
             
             

+ 7 - 1
Unity/Assets/HotfixView/Demo/Helper/LoadConfigHelper.cs

@@ -6,7 +6,7 @@ namespace ET
 {
 {
     public static class LoadConfigHelper
     public static class LoadConfigHelper
     {
     {
-        public static void LoadAllConfigBytes(Dictionary<string, byte[]> output)
+        public static void GetAllConfigBytes(Dictionary<string, byte[]> output)
         {
         {
             Dictionary<string, UnityEngine.Object> keys = ResourcesComponent.Instance.GetBundleAll("config.unity3d");
             Dictionary<string, UnityEngine.Object> keys = ResourcesComponent.Instance.GetBundleAll("config.unity3d");
 
 
@@ -17,5 +17,11 @@ namespace ET
                 output[key] = v.bytes;
                 output[key] = v.bytes;
             }
             }
         }
         }
+        
+        public static byte[] GetOneConfigBytes(string configName)
+        {
+            TextAsset v = ResourcesComponent.Instance.GetAsset("config.unity3d", configName) as TextAsset;
+            return v.bytes;
+        }
     }
     }
 }
 }

+ 0 - 83
Unity/Assets/Model/Generate/Message/OuterMessage.cs

@@ -389,87 +389,4 @@ namespace ET
 
 
 	}
 	}
 
 
-	[ResponseType(typeof(M2C_TestActorResponse))]
-	[Message(OuterOpcode.C2M_TestActorRequest)]
-	[ProtoContract]
-	public partial class C2M_TestActorRequest: Object, IActorLocationRequest
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-		[ProtoMember(91)]
-		public long ActorId { get; set; }
-
-		[ProtoMember(1)]
-		public string Info { get; set; }
-
-	}
-
-	[Message(OuterOpcode.M2C_TestActorResponse)]
-	[ProtoContract]
-	public partial class M2C_TestActorResponse: Object, IActorLocationResponse
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-		[ProtoMember(91)]
-		public int Error { get; set; }
-
-		[ProtoMember(92)]
-		public string Message { get; set; }
-
-		[ProtoMember(1)]
-		public string Info { get; set; }
-
-	}
-
-	[Message(OuterOpcode.PlayerInfo)]
-	[ProtoContract]
-	public partial class PlayerInfo: Object, IMessage
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-	}
-
-	[ResponseType(typeof(G2C_PlayerInfo))]
-	[Message(OuterOpcode.C2G_PlayerInfo)]
-	[ProtoContract]
-	public partial class C2G_PlayerInfo: Object, IRequest
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-	}
-
-	[Message(OuterOpcode.G2C_PlayerInfo)]
-	[ProtoContract]
-	public partial class G2C_PlayerInfo: Object, IResponse
-	{
-		[ProtoMember(90)]
-		public int RpcId { get; set; }
-
-		[ProtoMember(91)]
-		public int Error { get; set; }
-
-		[ProtoMember(92)]
-		public string Message { get; set; }
-
-		[ProtoMember(1)]
-		public PlayerInfo PlayerInfo { get; set; }
-
-		[ProtoMember(2)]
-		public List<PlayerInfo> PlayerInfos = new List<PlayerInfo>();
-
-		[ProtoMember(3)]
-		public List<string> TestRepeatedString = new List<string>();
-
-		[ProtoMember(4)]
-		public List<int> TestRepeatedInt32 = new List<int>();
-
-		[ProtoMember(5)]
-		public List<long> TestRepeatedInt64 = new List<long>();
-
-	}
-
 }
 }

+ 0 - 5
Unity/Assets/Model/Generate/Message/OuterOpcode.cs

@@ -24,10 +24,5 @@ namespace ET
 		 public const ushort C2G_LoginGate = 20020;
 		 public const ushort C2G_LoginGate = 20020;
 		 public const ushort G2C_LoginGate = 20021;
 		 public const ushort G2C_LoginGate = 20021;
 		 public const ushort G2C_TestHotfixMessage = 20022;
 		 public const ushort G2C_TestHotfixMessage = 20022;
-		 public const ushort C2M_TestActorRequest = 20023;
-		 public const ushort M2C_TestActorResponse = 20024;
-		 public const ushort PlayerInfo = 20025;
-		 public const ushort C2G_PlayerInfo = 20026;
-		 public const ushort G2C_PlayerInfo = 20027;
 	}
 	}
 }
 }