Przeglądaj źródła

命令行增加protocol参数,可以命令行指定使用tcp,kcp

tanghai 7 lat temu
rodzic
commit
b180b69f6b

+ 2 - 2
Server/App/Program.cs

@@ -48,7 +48,7 @@ namespace App
 				switch (startConfig.AppType)
 				{
 					case AppType.Manager:
-						Game.Scene.AddComponent<AppManagerComponent>();
+						Game.Scene.AddComponent<AppManagerComponent, NetworkProtocol>(options.Protocol);
 						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
 						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(options.Protocol, outerConfig.Address);
 						break;
@@ -92,7 +92,7 @@ namespace App
 						Game.Scene.AddComponent<NetInnerComponent, string>(innerConfig.Address);
 						Game.Scene.AddComponent<NetOuterComponent, NetworkProtocol, string>(options.Protocol, outerConfig.Address);
 						Game.Scene.AddComponent<LocationProxyComponent>();
-						Game.Scene.AddComponent<AppManagerComponent>();
+						Game.Scene.AddComponent<AppManagerComponent, NetworkProtocol>(options.Protocol);
 						Game.Scene.AddComponent<RealmGateAddressComponent>();
 						Game.Scene.AddComponent<GateSessionKeyComponent>();
 						Game.Scene.AddComponent<ConfigComponent>();

+ 7 - 5
Server/Model/Component/AppManagerComponent.cs

@@ -7,20 +7,22 @@ using System.Runtime.InteropServices;
 namespace ETModel
 {
 	[ObjectSystem]
-	public class AppManagerComponentStartSystem : StartSystem<AppManagerComponent>
+	public class AppManagerComponentAwakeSystem : AwakeSystem<AppManagerComponent, NetworkProtocol>
 	{
-		public override void Start(AppManagerComponent self)
+		public override void Awake(AppManagerComponent self, NetworkProtocol protocol)
 		{
-			self.Start();
+			self.Awake(protocol);
 		}
 	}
 
 	public class AppManagerComponent: Component
 	{
+		private NetworkProtocol networkProtocol;
 		private readonly Dictionary<int, Process> processes = new Dictionary<int, Process>();
 
-		public void Start()
+		public void Awake(NetworkProtocol protocol)
 		{
+			this.networkProtocol = protocol;
 			string[] ips = NetHelper.GetAddressIPs();
 			StartConfig[] startConfigs = StartConfigComponent.Instance.GetAll();
 			
@@ -51,7 +53,7 @@ namespace ETModel
 			string configFile = optionComponent.Options.Config;
 			StartConfig startConfig = startConfigComponent.Get(appId);
 			const string exe = "dotnet";
-			string arguments = $"App.dll --appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile}";
+			string arguments = $"App.dll --appId={startConfig.AppId} --appType={startConfig.AppType} --config={configFile} --protocol={this.networkProtocol}";
 
 			Log.Info($"{exe} {arguments}");
 			try