Преглед изворни кода

修改ET6服务器启动失败BUG (#170)

* Log输出到Console

* 使用Config前添加ConfigComponent
使用OuterAddress拼接好的外网地址
修改TimerComponent关于TimeOut相关代码
HongXiao пре 5 година
родитељ
комит
d7047073a5

+ 1 - 1
Server/App/NLog.config

@@ -51,7 +51,7 @@
 		<logger name="*" minlevel="Info" maxlevel="Info" writeTo="info" />
 		<logger name="*" minlevel="Warn" maxlevel="Warn" writeTo="warn" />
 		<logger name="*" minlevel="Error" maxlevel="Error" writeTo="error" />
-		<logger name="*" minlevel="Error" maxlevel="Error" writeTo="errorConsole" />
+		<logger name="*" minlevel="Trace" maxlevel="Error" writeTo="errorConsole" />
 		<logger name="*" minlevel="Fatal" maxlevel="Fatal" writeTo="fatal" />
 	</rules>
 </nlog>

+ 1 - 1
Server/Hotfix/Module/Actor/ActorMessageSenderComponentSystem.cs

@@ -28,7 +28,7 @@ namespace ET
     
     public static class ActorMessageSenderComponentSystem
     {
-        public static void Check(this ActorMessageSenderComponent self)
+        public static void Check(this ActorMessageSenderComponent self, bool isTimeOut)
         {
             long timeNow = TimeHelper.Now();
             foreach ((int key, ActorMessageSender value) in self.requestCallback)

+ 1 - 1
Server/Hotfix/Module/ActorLocation/ActorLocationSenderComponentSystem.cs

@@ -29,7 +29,7 @@ namespace ET
     
     public static class ActorLocationSenderComponentSystem
     {
-        public static void Check(this ActorLocationSenderComponent self)
+        public static void Check(this ActorLocationSenderComponent self, bool isTimeOut)
         {
             using (ListComponent<long> list = EntityFactory.Create<ListComponent<long>>(self.Domain))
             {

+ 2 - 1
Server/Hotfix/Module/Scene/AfterScenesAdd_CreateScene.cs

@@ -7,13 +7,14 @@ namespace ET
     {
         public override void Run()
         {
+            Game.Scene.AddComponent<ConfigComponent>();
+
             Options options = Game.Scene.GetComponent<Options>();
             StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(options.Process);
             
             Game.Scene.AddComponent<TimerComponent>();
             Game.Scene.AddComponent<OpcodeTypeComponent>();
             Game.Scene.AddComponent<MessageDispatcherComponent>();
-            Game.Scene.AddComponent<ConfigComponent>();
             Game.Scene.AddComponent<CoroutineLockComponent>();
             // 发送普通actor消息
             Game.Scene.AddComponent<ActorMessageSenderComponent>();

+ 2 - 2
Server/Hotfix/Module/Scene/SceneFactory.cs

@@ -20,10 +20,10 @@ namespace ET
             switch (scene.SceneType)
             {
                 case SceneType.Realm:
-                    scene.AddComponent<NetOuterComponent, string>($"{startSceneConfig.OuterPort}:{startSceneConfig.OuterPort}");
+                    scene.AddComponent<NetOuterComponent, string>(startSceneConfig.OuterAddress);
                     break;
                 case SceneType.Gate:
-                    scene.AddComponent<NetOuterComponent, string>($"{startSceneConfig.OuterPort}:{startSceneConfig.OuterPort}");
+                    scene.AddComponent<NetOuterComponent, string>(startSceneConfig.OuterAddress);
                     scene.AddComponent<PlayerComponent>();
                     scene.AddComponent<GateSessionKeyComponent>();
                     break;

+ 3 - 3
Unity/Assets/Model/Entity/TimerComponent.cs

@@ -93,7 +93,7 @@ namespace ET
 
 			try
 			{
-				this.Callback.Invoke(isTimeout);
+				this.Callback?.Invoke(isTimeout);
 			}
 			catch (Exception e)
 			{
@@ -292,14 +292,14 @@ namespace ET
 		/// <param name="time"></param>
 		/// <param name="action"></param>
 		/// <returns></returns>
-		public long NewRepeatedTimer(long time, Action action)
+		public long NewRepeatedTimer(long time, Action<bool> action)
 		{
 			if (time < 30)
 			{
 				throw new Exception($"repeated time < 30");
 			}
 			long tillTime = TimeHelper.Now() + time;
-			RepeatedTimer timer = EntityFactory.CreateWithParent<RepeatedTimer, long, Action>(this, time, action);
+			RepeatedTimer timer = EntityFactory.CreateWithParent<RepeatedTimer, long, Action<bool>>(this, time, action);
 			this.timers[timer.Id] = timer;
 			AddToTimeId(tillTime, timer.Id);
 			return timer.Id;

+ 2 - 5
Unity/Assets/Model/Module/Message/SessionIdleCheckComponent.cs

@@ -21,10 +21,7 @@
             RepeatedTimer repeatedTimer = TimerComponent.Instance.GetRepeatedTimer(self.RepeatedTimer);
             if (repeatedTimer != null)
             {
-                repeatedTimer.Callback = (isTimeout) =>
-                {
-                    self.Check();
-                };
+                repeatedTimer.Callback = self.Check;
             }
         }
     }
@@ -44,7 +41,7 @@
     
     public static class SessionIdleCheckerComponentSystem
     {
-        public static void Check(this SessionIdleCheckerComponent self)
+        public static void Check(this SessionIdleCheckerComponent self, bool isTimeOut)
         {
             Session session = self.GetParent<Session>();
             long timeNow = TimeHelper.Now();