Esempio n. 1
0
        public void RequestGetAccount(MonoBehaviour mono, U3DTypeBaseData _in_data, TypeHttpCBKDelegate cbkdelegate, UnityEngine.Object crossData)
        {
            string url = REQUEST_ADDRESS + "/get_account";
            Dictionary <string, object> data = changeBaseDataToHttpPostData(_in_data);

            Debug.Log("RequestLogin " + url + data.ToString());

            mono.StartCoroutine(HttpPost(url, data, cbkdelegate, crossData));
        }
Esempio n. 2
0
//		private const string REQUEST_ADDRESS = "http://120.27.137.35:40001/game";
        public void RequestLogin(MonoBehaviour mono, U3DTypeBaseData _in_data, TypeHttpCBKDelegate cbkdelegate, UnityEngine.Object crossData)
        {
            string url = REQUEST_ADDRESS + "/login";

//			Debug.Log("request baidu" + url);
//			mono.StartCoroutine( HttpGet("http://www.baidu.com", cbkdelegate, crossData) );

            Dictionary <string, object> data = changeBaseDataToHttpPostData(_in_data);

            Debug.Log("RequestLogin " + url + data.ToString());
            mono.StartCoroutine(HttpPost(url, data, cbkdelegate, crossData));
        }
Esempio n. 3
0
        //GET请求
        public IEnumerator HttpGet(string url, TypeHttpCBKDelegate cbkFunc, UnityEngine.Object crossData)
        {
            WWW getData = new WWW(url);

            yield return(getData);

            if (getData.error != null)
            {
                //GET请求失败
                Debug.Log("error is :" + getData.error);
                cbkFunc(getData.text, crossData);
            }
            else
            {
                //GET请求成功
                Debug.Log("request ok : " + getData.text);
                cbkFunc(getData.text, crossData);
            }
        }
Esempio n. 4
0
        //GET请求


        public IEnumerator HttpPost(string url, Dictionary <string, string> postData, TypeHttpCBKDelegate cbkFunc, UnityEngine.Object crossData)
        {
            Debug.Log("create wwwform");
            WWWForm form = new WWWForm();

            foreach (string key in postData.Keys)
            {
                Debug.Log("read post data add " + postData[key]);
                form.AddField(key, postData[key]);
            }
            Debug.Log("create form finish");

            Debug.Log("start httppost :" + url);
            WWW getData = new WWW(url, form);

            yield return(getData);

            if (getData.error != null)
            {
                //GET请求失败
                Debug.Log("error is :" + getData.error);
                cbkFunc(getData.error, crossData);
            }
            else
            {
                //GET请求成功
                Debug.Log("request ok : " + getData.text);
                cbkFunc(getData.text, crossData);
            }
        }