ソースを参照

Merge branch 'master' of http://10.108.64.190:3000/gfg/client

zhaoyang 2 年 前
コミット
fb8ab97089

+ 21 - 1
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Login/LoginHelper.cs

@@ -1,5 +1,6 @@
 using System;
 using GFGGame;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
 
 namespace ET
 {
@@ -415,9 +416,16 @@ namespace ET
         public static async ETTask<(int, string)> ReqRandomRoleName()
         {
             A2C_GetRandomRoleName response = null;
+            bool notLogin = false;
+            Session accountSession = GameGlobal.zoneScene.GetComponent<SessionComponent>().AccountSession;
+            if (accountSession == null || accountSession.IsDisposed)
+            {
+                notLogin = true;
+                accountSession = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameConfig.LoginAddress));
+            }
             try
             {
-                response = (A2C_GetRandomRoleName)await GameGlobal.zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_GetRandomRoleName()
+                response = (A2C_GetRandomRoleName)await accountSession?.Call(new C2A_GetRandomRoleName()
                 {
                     ServerId = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>().CurrentServerId
                 });
@@ -425,15 +433,27 @@ namespace ET
             catch (Exception e)
             {
                 Log.Debug(e.ToString());
+                if(notLogin)
+                {
+                    accountSession?.Dispose();
+                }
                 return (ErrorCode.ERR_NetWorkError, "");
             }
 
             if (response.Error != ErrorCode.ERR_Success)
             {
                 //Log.Error(response.Error.ToString());
+                if (notLogin)
+                {
+                    accountSession?.Dispose();
+                }
                 return (ErrorCode.ERR_NetWorkError, "");
             }
 
+            if (notLogin)
+            {
+                accountSession?.Dispose();
+            }
             return (ErrorCode.ERR_Success, response.Name);
         }
     }