Browse Source

修改了Ice在连接后communicate()会立即dispose的bug

大爷 2 years ago
parent
commit
3d31edbf19

+ 13 - 4
DotNet/Hotfix/IceBattle/BattleIceAgentComponentSystem.cs

@@ -1,5 +1,6 @@
 using Ice;
 using System;
+using System.Threading;
 using System.Threading.Tasks;
 
 namespace ET.Server
@@ -13,8 +14,12 @@ namespace ET.Server
             {
                 BattleIceAgentComponent.Instance = self;
 
-                self.IceApp = new IceApp();
-                self.IceApp.main(new string[0], "../Config/ice.config");
+                Thread thread = new Thread(() =>
+                {
+                    self.IceApp = new IceApp();
+                    self.IceApp.main(new string[0], "../Config/ice.config");
+                });
+                thread.Start();
             }
         }
 
@@ -22,6 +27,7 @@ namespace ET.Server
         {
             protected override void Destroy(BattleIceAgentComponent self)
             {
+                Log.Info($"Ice component destroyed");
                 Ice.Application.communicator().Dispose();
             }
         }
@@ -49,9 +55,10 @@ namespace ET.Server
                     ZoneIce.ice_getCachedConnection().setAdapter(adapter);
                     ZoneIce.setCallback(prx.ice_getIdentity(), Global.GameServerUUID);
 
-                    //测试一下ice接口
+                    //向战斗服注册本GameServer
                     var res = ZoneIce.registerGameServer(Global.GameServerId, Global.GameServerId);
-                    Log.Debug($"registerGameServer ret:  {res}");
+                    BattleIceAgentComponent.Instance.StrBattleServerVersion = res;
+                    Log.Info($"Battle Server version:  {res}");
                 }
                 catch(Ice.Exception e)
                 {
@@ -77,6 +84,8 @@ namespace ET.Server
                     return 2;
                 }
 
+                communicator().waitForShutdown();
+                Log.Info("ice thread end");
                 return 0;
             }
         }

+ 2 - 0
DotNet/Model/Module/IceBattle/BattleIceAgentComponent.cs

@@ -15,5 +15,7 @@ namespace ET.Server
         public Ice.Application IceApp;
         public BattleIce.ZoneManagerPrx IceZoneManager;
         public BattleIce.XmdsManagerPrx IceXmdsManager;
+
+        public string StrBattleServerVersion;
     }
 }