yyl
2026-02-11 1ad03cc2f91d75e80fc3dc42e2ac1fadc9a2bfec
Main/Core/NetworkPackage/GameNetSystem.cs
@@ -118,6 +118,12 @@
        }
        mainSocket = new ClientSocket(ServerType.Main);
        //  websocket的断开链接需要处理一下
        mainSocket.OnDisconnected = () =>
        {
            netState = NetState.DisConnected;
            LoginManager.Instance.busy = false;
        };
        mainProtocolQueue.Clear();
        mainSocket.Connect(ip, port, (bool ok) =>
@@ -141,6 +147,27 @@
        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.LogError($"重点提醒:0403登录后 发送缓存包数量 {cnt} 个");
    }
    public void SendInfo(GameNetPackBasic protocol)
    {
        if (waitLogin)
@@ -152,11 +179,13 @@
            }
        }
        // 0102是从地图发送的 说明已登录,但可能卡顿导致通知route状态慢于客户端,依然需要防范
        if (waitLoginMap)
        {
            if (protocol is not C0123_tagCClientPackVersion && protocol is not C0101_tagCPlayerLogin)
            {
                Debug.LogWarning("等待0403包,不允许发送其他包 " + protocol.ToString());
                Debug.LogError("重点提醒:登录完成前的封包先加入队列 等0403回包后再一起发送服务端 " + protocol.ToString());
                sendQueue.Enqueue(protocol);
                return;
            }
        }
@@ -168,6 +197,7 @@
        }
    }
#if UNITY_EDITOR
    public void SendInfo(byte[] vBytes)
    {
        if (mainSocket != null)
@@ -175,7 +205,7 @@
            mainSocket.SendInfo(vBytes);
        }
    }
#endif
    public void PushPackage(GameNetPackBasic protocol, ServerType type)
    {
@@ -286,6 +316,8 @@
    void OnUpdate()
    {
        mainSocket?.DispatchMessageQueue();
        lock (this)
        {
            while (mainProtocolQueue.Count > 0)