コード例 #1
0
        private IEnumerator httpDownload(OnHttpDone handler, string url, string filename)
        {
            using (WWW www = new WWW(url))
            {
                yield return(www);

                string msg;
                bool   isSuc;
                if (www.error != null)
                {
                    isSuc = false;
                    msg   = www.error;
                }
                else
                {
                    isSuc = true;
                    msg   = BaseUtil.FileUtility.GetFileReadPath(filename, true);
                    BaseUtil.FileUtility.WriteFile(filename, www.bytes);
                }
                if (null != handler)
                {
                    handler(isSuc, msg);
                }
            }
        }
コード例 #2
0
        public void HttpUpload(OnHttpDone handler, string url, string fileField, byte[] upFile, params string[] dataParams)
        {
            WWWForm data = Utils.GetWWWPostData(dataParams);

            data.AddBinaryData(fileField, upFile);
            StartCoroutine(httpDo(handler, url, data));
        }
コード例 #3
0
        public void HttpDownload(OnHttpDone handler, string url, string filename, params string[] dataParams)
        {
            string paramStr = Utils.GetHttpHead(dataParams);

            if (!string.IsNullOrEmpty(paramStr))
            {
                url = url + '?' + paramStr;
            }
            StartCoroutine(httpDownload(handler, url, filename));
        }
コード例 #4
0
        private IEnumerator httpDo(OnHttpDone handler, string url, WWWForm data = null)
        {
            using (WWW www = (null == data)? new WWW(url):new WWW(url, data))
            {
                yield return(www);

                string msg;
                bool   isSuc;
                if (www.error != null)
                {
                    isSuc = false;
                    msg   = www.error;
                }
                else
                {
                    isSuc = true;
                    msg   = www.text;
                }
                if (null != handler)
                {
                    handler(isSuc, msg);
                }
            }
        }
コード例 #5
0
        public void HttpPost(OnHttpDone handler, string url, params string[] dataParams)
        {
            WWWForm data = Utils.GetWWWPostData(dataParams);

            StartCoroutine(httpDo(handler, url, data));
        }