示例#1
0
    private void CallResult(IPGeolocationDetail detail)
    {
        if (isCallResult)
        {
            return;
        }

        if (detail == null)
        {
            errorCallBackCount++;
            if (errorCallBackCount >= maxRequest)
            {
                if (OnIPGeolocationCallBack != null)
                {
                    OnIPGeolocationCallBack(detail);
                }
                Destroy(gameObject);
            }
            return;
        }

        isCallResult = true;


        if (OnIPGeolocationCallBack != null)
        {
            OnIPGeolocationCallBack(detail);
        }
        // Destroy(gameObject);
    }
示例#2
0
 private void RunHttpQuest(string uri, ParseJsonReultCallBack callBack)
 {
     maxRequest++;
     StartCoroutine(GetHttpResult(uri, (res) =>
     {
         if (!string.IsNullOrEmpty(res.error))
         {
             Debug.LogError(res.uri + " GetHttpResult error:" + res.error);
             CallResult(null);
             return;
         }
         IPGeolocationDetail detail = new IPGeolocationDetail();
         detail.formURI             = uri;
         detail.useTime             = Time.realtimeSinceStartup - res.startRequestTime;
         try
         {
             callBack(detail, res.result);
             Debug.Log(uri + " 返回信息:[" + detail.useTime + "]\n res:" + res.result);
             CallResult(detail);
         }
         catch (Exception e)
         {
             CallResult(null);
             Debug.LogError(res.uri + "GetHttpResult 解析失败:" + res.result + "\n" + e);
         }
     }));
 }
    private void ReciveIPDetail(IPGeolocationDetail detail)
    {
        if (detail == null)
        {
            retryTimes++;
            if (retryTimes > 1)
            {
                retryTimes = 0;
                RunDownloadRegionServer();
            }
            else
            {
                OnFlowStart();
            }

            return;
        }
        iPGeolocationDetail = detail;
        if (detail.country_code == "CN")
        {
            IsChinaIP = true;
        }
        Debug.Log("IP地区:" + detail.ipv4 + " 国家:" + detail.country);

        flowManager.SetVariable(P_IPGeolocationDetail, detail);

        RunDownloadRegionServer();
    }
    private void ReciveIPDetail(IPGeolocationDetail detail)
    {
        if (detail == null)
        {
            retryTimes++;
            if (retryTimes > 1)
            {
                retryTimes = 0;
                RunDownloadRegionServer();
            }
            else
            {
                OnFlowStart();
            }

            return;
        }
        iPGeolocationDetail = detail;
        if (detail.country_code == "CN")
        {
            IsChinaIP = true;
        }
        Debug.Log("IP地区:" + detail.ipv4 + " 国家:" + detail.country);
        GameInfoCollecter.AddNetworkStateInfoValue("Device IP", detail.ipv4);
        GameInfoCollecter.AddNetworkStateInfoValue("Device IP Country", detail.country);
        GameInfoCollecter.AddNetworkStateInfoValue("Device IP Country Code", detail.country_code);

        flowManager.SetVariable(P_IPGeolocationDetail, detail);

        RunDownloadRegionServer();
    }
 private static void OnDownloadRegionServerListFlowItemFinish(FlowItemBase arg1, string arg2)
 {
     iPGeolocationDetail = FlowManager.GetFlowItem <DownloadRegionServerListFlowItem>().iPGeolocationDetail;
     IsChinaIP           = FlowManager.GetFlowItem <DownloadRegionServerListFlowItem>().IsChinaIP;
 }