Exemple #1
0
    public IEnumerator BeginTimeOutNoRe(int mNum, int mNumCon, ActionCon actionConnect, Action action, Action actionTimeOut)
    {
        isStartTimeOut = true;
        objLoading.SetActive(true);
        if (actionConnect != null)
        {
            yield return(StartCoroutine(actionConnect(mNumCon)));
        }
        if (action != null)
        {
            action();
        }
        int outTime = 0;

        while (true)
        {
            yield return(new WaitForSeconds(1));

            outTime++;
            if (outTime >= mNum || !YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerConnected || !isStartTimeOut)
            {
                break;
            }
        }

        //yield return new WaitForSeconds(mNum);
        if (isStartTimeOut)
        {
//            NGUIDebug.Log("==timeout :" + action.Target.ToString() + "\n");
            if (isTDlogin)
            {
                //TD_info.loginFail();
                isTDlogin = false;
            }
            if (isTDselet)
            {
                //TD_info.selectFail(PlayerPrefs.GetString("InAppServerName", "NON"));
                isTDselet = false;
            }

            warnings.warningAllEnter.Show(StaticLoc.Loc.Get("info358"), StaticLoc.Loc.Get("info720"));
            objLoading.SetActive(false);
            isStartTimeOut = false;
            if (actionTimeOut != null)
            {
                actionTimeOut();
            }
        }
    }
Exemple #2
0
 public void RunBeginTimeOut(int mNum, int mNumCon, ActionCon actionConnect, Action action, Action actionTimeOut)
 {
     StartCoroutine(BeginTimeOut(mNum, mNumCon, actionConnect, action, actionTimeOut));
 }
Exemple #3
0
    /// <summary>
    /// 开始超时记录
    /// </summary>
    /// <returns>
    ///
    /// </returns>
    /// <param name='mNum'>
    /// 超时时间
    /// </param>
    /// <param name='mNum'>
    /// 连接超时时间
    /// </param>
    /// <param name='actionConnect'>
    /// 连接方法
    /// </param>
    /// <param name='action'>
    /// 执行方法
    /// </param>
    public IEnumerator BeginTimeOut(int mNum, int mNumCon, ActionCon actionConnect, Action action, Action actionTimeOut)
    {
        try{
            isStartTimeOut = true;
            objLoading.SetActive(true);
        }catch (System.Exception ex) {
            Debug.Log("BeginTimeOut___try_01" + ex.ToString());
        }
        if (actionConnect != null)
        {
            yield return(StartCoroutine(actionConnect(mNumCon)));
        }
        if (action != null)
        {
            action();
        }
        int outTime = 0;

        while (true)
        {
            yield return(new WaitForSeconds(1));

            try{
                outTime++;
                if (actionConnect == ConnectYuanUnity)
                {
                    if (outTime >= mNum || !YuanUnityPhoton.GetYuanUnityPhotonInstantiate().ServerConnected || !isStartTimeOut)
                    {
                        break;
                    }
                }
                else
                {
                    if (outTime >= mNum || !InRoom.GetInRoomInstantiate().ServerConnected || !isStartTimeOut)
                    {
                        break;
                    }
                }
            }catch (System.Exception ex) {
                Debug.Log("BeginTimeOut___try_02" + ex.ToString());
            }
        }

        //yield return new WaitForSeconds(mNum);
        try{
            if (isStartTimeOut)
            {
//				NGUIDebug.Log("==timeout :" + action.Target.ToString() + "\n");
                if (isTDlogin)
                {
                    //TD_info.loginFail();
                    isTDlogin = false;
                }

                if (isTDselet)
                {
                    //TD_info.selectFail(PlayerPrefs.GetString("InAppServerName", "NON"));
                    isTDselet = false;
                }

                warnings.warningAllTimeOut.ShowTimeOut(StaticLoc.Loc.Get("info358"), StaticLoc.Loc.Get("info720"), () => RunBeginTimeOut(mNum, mNumCon, actionConnect, action, actionTimeOut));
                objLoading.SetActive(false);
                isStartTimeOut = false;
                if (actionTimeOut != null)
                {
                    actionTimeOut();
                }
            }
        }catch (System.Exception ex) {
            Debug.Log("BeginTimeOut___try_03" + ex.ToString());
        }
    }