From 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 11 五月 2026 16:20:37 +0800
Subject: [PATCH] Merge branch 'master' into h5version

---
 Main/Core/NetworkPackage/GameNetSystem.cs |   73 +++++++++++++++++++++++++++++++++++-
 1 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/Main/Core/NetworkPackage/GameNetSystem.cs b/Main/Core/NetworkPackage/GameNetSystem.cs
index 6ce7feb..e3033f9 100644
--- a/Main/Core/NetworkPackage/GameNetSystem.cs
+++ b/Main/Core/NetworkPackage/GameNetSystem.cs
@@ -2,10 +2,15 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using Cysharp.Threading.Tasks;
 
 
 public class GameNetSystem : Singleton<GameNetSystem>
 {
+    //闄愬埗瀹㈡埛绔殑涓嬩竴涓寘鏄櫥褰曞寘C0101_tagCPlayerLogin锛屽鏋滀笉鏄櫥褰曞寘涓嶅厑璁稿彂閫�
+    bool waitLogin = false; //绛夊緟鍙戦�佺櫥褰曞寘锛屽鏋滄湁鍏朵粬鍖呯洿鎺ュ睆钄斤紝閬垮厤鏂嚎閲嶈繛鐨勬儏鍐靛彂浜嗘敾鍑诲寘涔嬬被鐨�
+    //绛夊緟鏈嶅姟绔�0403鐨勫寘鍚庢墠鑳藉彂鍏朵粬鐨勫姛鑳藉寘锛屽彧鏈塁0123_tagCClientPackVersion 鍜� C0101_tagCPlayerLogin 鍙互鍙戦��  
+    bool waitLoginMap = false; 
     NetUpdateBehaviour m_NetUpdateBehaviour;
     NeverConnectState neverConnectState;
     AccountLoginState accountLoginState;
@@ -113,7 +118,15 @@
             Debug.Log(ex);
         }
 
+        Debug.unityLogger.logEnabled = true;
+
         mainSocket = new ClientSocket(ServerType.Main);
+        //  websocket鐨勬柇寮�閾炬帴闇�瑕佸鐞嗕竴涓�
+        mainSocket.OnDisconnected = () =>
+        {
+            netState = NetState.DisConnected;
+            LoginManager.Instance.busy = false;
+        };
         mainProtocolQueue.Clear();
 
         mainSocket.Connect(ip, port, (bool ok) =>
@@ -125,8 +138,61 @@
         });
     }
 
+    //闄愬埗瀹㈡埛绔殑涓嬩竴涓寘鏄櫥褰曞寘C0101_tagCPlayerLogin锛屽鏋滀笉鏄櫥褰曞寘涓嶅厑璁稿彂閫�
+    public void SetIsWaitLogin(bool _wait)
+    {
+        waitLogin = _wait;
+    }
+
+    //绛夊緟鏈嶅姟绔�0403鐨勫寘鍚庢墠鑳藉彂鍏朵粬鐨勫姛鑳藉寘锛屽彧鏈塁0123_tagCClientPackVersion 鍜� C0101_tagCPlayerLogin 鍙互鍙戦��
+    public void SetIsWaitLoginMap(bool _wait)
+    {
+        waitLoginMap = _wait;
+    }
+
+    public bool GetIsWaitLoginMap()
+    {
+        return waitLoginMap;
+    }
+
+    //0403鐧诲綍涔嬪墠鐨勫寘缂撳瓨
+    Queue<GameNetPackBasic> sendQueue = new Queue<GameNetPackBasic>();
+
+    public void SendCachePackage()
+    {
+        int cnt = sendQueue.Count;
+        if (mainSocket != null)
+        {
+            while (sendQueue.Count > 0)
+            {
+                SendInfo(sendQueue.Dequeue());
+            }
+        }
+        Debug.Log($"閲嶇偣鎻愰啋锛�0403鐧诲綍鍚� 鍙戦�佺紦瀛樺寘鏁伴噺 {cnt} 涓�");
+    }
+
     public void SendInfo(GameNetPackBasic protocol)
     {
+        if (waitLogin)
+        {
+            if (protocol is not C0101_tagCPlayerLogin)
+            {
+                Debug.LogWarning("绛夊緟鎵ц鐧诲綍锛屼笉鍏佽鍙戦�佸叾浠栧寘 " + protocol.ToString());
+                return;
+            }
+        }
+
+        // 0102鏄粠鍦板浘鍙戦�佺殑 璇存槑宸茬櫥褰曪紝浣嗗彲鑳藉崱椤垮鑷撮�氱煡route鐘舵�佹參浜庡鎴风锛屼緷鐒堕渶瑕侀槻鑼�
+        if (waitLoginMap)
+        {
+            if (protocol is not C0123_tagCClientPackVersion && protocol is not C0101_tagCPlayerLogin)
+            {
+                Debug.Log("閲嶇偣鎻愰啋锛氱櫥褰曞畬鎴愬墠鐨勫皝鍖呭厛鍔犲叆闃熷垪 绛�0403鍥炲寘鍚庡啀涓�璧峰彂閫佹湇鍔$ " + protocol.ToString());
+                sendQueue.Enqueue(protocol);
+                return;
+            }
+        }
+
         if (mainSocket != null)
         {
             mainSocket.SendInfo(protocol);
@@ -134,6 +200,7 @@
         }
     }
 
+#if UNITY_EDITOR
     public void SendInfo(byte[] vBytes)
     {
         if (mainSocket != null)
@@ -141,7 +208,7 @@
             mainSocket.SendInfo(vBytes);
         }
     }
-
+#endif
 
     public void PushPackage(GameNetPackBasic protocol, ServerType type)
     {
@@ -235,7 +302,7 @@
 
             LoginManager.Instance.busy = false;
 
-            StageManager.Instance.ReturnToLoginScene();
+            StageManager.Instance.ReturnToLoginScene().Forget();
             NetLinkWin.Hide();
         }
     }
@@ -252,6 +319,8 @@
 
     void OnUpdate()
     {
+        mainSocket?.DispatchMessageQueue();
+
         lock (this)
         {
             while (mainProtocolQueue.Count > 0)

--
Gitblit v1.8.0