Procházet zdrojové kódy

优化服务端代码,服务器日志

johnclot69 před 1 rokem
rodič
revize
9837c953ea

+ 4 - 2
DotNet/App/Program.cs

@@ -17,14 +17,16 @@ namespace ET
             Entry.Init();
             Init.Start();
             
+            long nowMS = DateTime.Now.Ticks;
             while (true)
             {
-                Thread.Sleep(1);
+                Thread.Sleep(15);
                 try
                 {
-                    Init.Update();
+                    Init.Update((int)((DateTime.Now.Ticks - nowMS)/10000));
                     Init.LateUpdate();
                     Init.FrameFinishUpdate();
+                    nowMS = DateTime.Now.Ticks;
                 }
                 catch (Exception e)
                 {

+ 1 - 0
DotNet/Hotfix/EntryEvent2_InitServer.cs

@@ -20,6 +20,7 @@ namespace ET.Server
             Root.Instance.Scene.AddComponent<NavmeshComponent>();
 
             StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Options.Instance.Process);
+            Log.Debug($"AppType: {Options.Instance.AppType}");
             switch (Options.Instance.AppType)
             {
                 case AppType.Server:

+ 2 - 2
DotNet/Loader/Init.cs

@@ -42,9 +42,9 @@ namespace ET
 			}
 		}
 
-		public static void Update()
+		public static void Update(int timeMS)
 		{
-			Game.Update();
+			Game.Update(timeMS);
 		}
 
 		public static void LateUpdate()

+ 1 - 0
Unity/Assets/Scripts/Codes/Model/Share/Entry.cs

@@ -29,6 +29,7 @@
         
         private static async ETTask StartAsync()
         {
+            Log.Debug("Entry start");
             WinPeriod.Init();
             
             MongoHelper.Init();

+ 1 - 1
Unity/Assets/Scripts/Core/Module/Config/ConfigComponent.cs

@@ -78,7 +78,7 @@ namespace ET
 		private void LoadOneInThread(Type configType, byte[] oneConfigBytes)
 		{
 			object category = SerializeHelper.Deserialize(configType, oneConfigBytes, 0, oneConfigBytes.Length);
-			
+			Log.Debug($"Deserialize: {configType} ok");
 			lock (this)
 			{
 				ISingleton singleton = category as ISingleton;

+ 1 - 1
Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -23,7 +23,7 @@ namespace ET
             this.nextFrameRun.Clear();
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             // 循环过程中会有对象继续加入队列
             while (this.nextFrameRun.Count > 0)

+ 3 - 3
Unity/Assets/Scripts/Core/Module/Entity/Scene.cs

@@ -34,7 +34,7 @@ namespace ET
             this.Parent = parent;
             this.Domain = this;
             this.IsRegister = true;
-            Log.Info($"scene create: {this.SceneType} {this.Name} {this.Id} {this.InstanceId} {this.Zone}");
+            Log.Info($"scene create: sceneType={this.SceneType}, name={this.Name}, id={this.Id}, instanceId={this.InstanceId}, zone={this.Zone}");
         }
 
         public Scene(long id, long instanceId, int zone, SceneType sceneType, string name, Entity parent)
@@ -49,14 +49,14 @@ namespace ET
             this.Parent = parent;
             this.Domain = this;
             this.IsRegister = true;
-            Log.Info($"scene create: {this.SceneType} {this.Name} {this.Id} {this.InstanceId} {this.Zone}");
+            Log.Info($"scene create: sceneType={this.SceneType}, name={this.Name}, id={this.Id}, instanceId={this.InstanceId}, zone={this.Zone}");
         }
 
         public override void Dispose()
         {
             base.Dispose();
             
-            Log.Info($"scene dispose: {this.SceneType} {this.Name} {this.Id} {this.InstanceId} {this.Zone}");
+            Log.Info($"scene dispose: sceneType={this.SceneType}, name={this.Name}, id={this.Id}, instanceId={this.InstanceId}, zone={this.Zone}");
         }
 
         public new Entity Domain

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

@@ -505,7 +505,7 @@ namespace ET
             }
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             Queue<long> queue = this.queues[(int)InstanceQueueIndex.Update];
             int count = queue.Count;

+ 1 - 1
Unity/Assets/Scripts/Core/Module/Synchronization/MainThreadSynchronizationContext.cs

@@ -13,7 +13,7 @@ namespace ET
             SynchronizationContext.SetSynchronizationContext(this.threadSynchronizationContext);
         }
         
-        public void Update()
+        public void Update(int timeMS)
         {
             this.threadSynchronizationContext.Update();
         }

+ 1 - 1
Unity/Assets/Scripts/Core/Module/Time/TimeInfo.cs

@@ -33,7 +33,7 @@ namespace ET
             this.FrameTime = this.ClientNow();
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             this.FrameTime = this.ClientNow();
         }

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

@@ -81,7 +81,7 @@ namespace ET
             return TimeHelper.ClientFrameTime();
         }
 
-        public void Update()
+        public void Update(int timeMS)
         {
             if (this.TimeId.Count == 0)
             {

+ 2 - 2
Unity/Assets/Scripts/Core/Singleton/Game.cs

@@ -59,7 +59,7 @@ namespace ET
             await task;
         }
 
-        public static void Update()
+        public static void Update(int timeMS)
         {
             int count = updates.Count;
             while (count-- > 0)
@@ -79,7 +79,7 @@ namespace ET
                 updates.Enqueue(singleton);
                 try
                 {
-                    update.Update();
+                    update.Update(timeMS);
                 }
                 catch (Exception e)
                 {

+ 1 - 1
Unity/Assets/Scripts/Core/Singleton/ISingletonUpdate.cs

@@ -2,6 +2,6 @@
 {
     public interface ISingletonUpdate
     {
-        void Update();
+        void Update(int timeMS);
     }
 }