Exemple #1
0
    public void ProcessMsg(DGPKG msg)
    {
//		Debug.Log("Start ProcessMsg");
        // 通过模块注册消息响应函数处理
        if (msg == null)
        {
            return;
        }

//		Debug.Log("ProcessMsg : " + (msg != null));
        if (msg.header.seq == 0)
        {
            NotifyMsgHandleMgr.Instance.HandleMsg(msg);
        }
        else
        {
            MsgInfo info = GetMsgInfo((int)msg.header.seq);
            if (info == null) // 最大的可能是,seq对应的响应来了多次(因为在目前的消息重发机制下,客户端可能会将具有同一seq的请求重发多次)
            {
                RemoveAlreadySentMsgBySeq(msg.header.seq);
            }
            else
            {
                RemoveAlreadySentMsg(info);

                //ssGame.NetDelay = Time.realtimeSinceStartup*1000 - msg.stHead.dwClientTime;
                if (info.Callback != null)
                {
                    if (msg.header != null && msg.body != null)
                    {
//                        Debug.Log("ProcessMsg : " + msg.header.msg_full_name);
                        //Debug.Log("ProcessMsg here GetType: " + msg.body.GetType());
                        //Debug.Log("ProcessMsg rsper: " + info.Callback.Target);
                        string fullName = msg.header.msg_full_name;
                        string typeName = msg.body.GetType().FullName;
                        if (fullName == typeName)
                        {
                            info.Callback(CSMsgResult.NoError, msg);
                        }
                        else
                        {
                            Debug.LogError(string.Format("{0} != {1}", fullName, typeName));
                        }
                        info.Reset();
                    }
                }
            }

            // 只要还有尚未被响应的请求,这里就不主动解锁
            if (!IsAnyRequestNotResponded())
            {
                UnlockScreen();
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// 清理登陆状态,关闭Socket,对于之前没有处理的消息统一回调
    /// </summary>
    /// <param name="result"></param>
    public void HandleNetworkError(CSMsgResult result, int errorCode = 0, bool showTips = true)
    {
        mShowErrTips = false;
        for (int i = 0; i < kCSMsgCallArrayLength; i++)
        {
            MsgInfo info = GetMsgInfo(i);
            if (info != null && info.Callback != null)
            {
                try
                {
                    info.Callback(result, null);
                }
                catch (Exception)
                {
                }
                RemoveAlreadySentMsg(info);
                RemoveWaitSendMsg(info);
                info.Reset();

                UnlockScreen();
            }
        }
        string msgContent = string.Empty;

        switch (result)
        {
        case CSMsgResult.MsgTimeOut:
            msgContent = LoginMgr.Instance.SvrHost + "MsgTimeOut";
            break;

        case CSMsgResult.NetworkError:
        {
            msgContent = LoginMgr.Instance.SvrHost + "NetworkErrorWithCode :" + errorCode;
        }
        break;

        case CSMsgResult.InternalError:
            msgContent = LoginMgr.Instance.SvrHost + "InternalError";
            break;
        }

        Debug.LogError(msgContent);
    }
Exemple #3
0
    private void ResetNetworkImpl()
    {
        Debuger.Log("ResetNetworkImpl");
        //MenuLoading.ForceDeleteObject();

        for (int i = 0; i < kCSMsgCallArrayLength; i++)
        {
            MsgInfo info = GetMsgInfo(i);
            if (info != null)
            {
                RemoveAlreadySentMsg(info);
                RemoveWaitSendMsg(info);
                info.Reset();
            }
        }

        if (mCSMsgWaitSendList != null)
        {
            mCSMsgWaitSendList.Clear();
        }

        /*if (mCSMsgSentList != null)
         *  mCSMsgSentList.Clear();*/

        if (mGameServerHandler != null)
        {
            mGameServerHandler.Close();
        }

        //bCryptProtocol = false;
        // for test
        bCryptProtocol = true;
        byte[] keys = System.Text.Encoding.Default.GetBytes("WLWLWLWLWLWLWLWL");
        System.Buffer.BlockCopy(keys, 0, CryptKey, 0, 16);

        /*if (ViewSplash.Instance != null)
         * {
         *  ViewSplash.Instance.handleShowLogin();
         * }*/
    }