コード例 #1
0
ファイル: HttpDns.cs プロジェクト: xubingyue/hugula
        public static void GetHttpDnsIP(string strUrl, System.Action <string, string> onComplete)
        {
            string url = string.Format("http://119.29.29.29/d?dn={0}", strUrl); System.Action <CRequest> onEnd = delegate(CRequest req) {
                string   text   = req.data.ToString();
                string[] strIps = text.Split(';');
                string   strIp  = strIps[0];
                onComplete(strUrl, strIp);
            };

            Debug.Log("ResourcesLoader.HttpRequest:" + url);
            // ResourcesLoader.HttpRequest (url, null, typeof (string), onEnd, null);
            ResourcesLoader.UnityWebRequest(url, null, typeof(string), onEnd, null);
        }
コード例 #2
0
ファイル: HttpLoadOperation.cs プロジェクト: xubingyue/hugula
        bool _Update()
        {
            string url = HttpDns.GetUrl(cRequest.url);  // get dsn ip

            if (string.IsNullOrEmpty(url))
            {
                return(true); //wait for ip
            }

            if (url != cRequest.url)
            {
                var headers = cRequest.head;
                if (headers == null)
                {
                    headers       = new WebHeaderCollection();
                    cRequest.head = headers;
                }

                if (string.IsNullOrEmpty(headers.Get("host")))
                {
                    headers.Add("host", new System.Uri(cRequest.url).Host);
                }
                // Debug.LogFormat("request ip {0}  override host {1} ",url,cRequest.overrideHost);
                ResourcesLoader.UnityWebRequest(cRequest);
            }
            else if (originalOperation != null)
            {
                Debug.LogFormat(" dns resolve fail request url {0}   ", url);
                ResourcesLoader.ProcessFinishedOperation(originalOperation);
            }
            else
            {
                Debug.LogFormat("dns resolve fail , complete request url {0} ", url);

                cRequest.DispatchEnd();

                if (cRequest.group != null)
                {
                    cRequest.group.Complete(cRequest, true);
                }

                cRequest.ReleaseToPool();
            }

            return(false);
        }