Esempio n. 1
0
    public static void Http(string url, string data, LuaFunction callback)
    {
        if (callBack == null)
        {
            callBack = LuaBehaviour.luaEnv.Global.Get <CallBack>("callBack");
        }
        Debug.Log("杨洋  url == " + url);
        if (url == "")
        {
            url = "http://" + GameConfig.ServerIP + "/SceneServer";
        }
        Debug.Log("杨洋  url == " + url + "   data ==   " + data);
        HTTPRequest client = new HTTPRequest(url, "POST", 5000, (HTTPResponse response) => {
            if (response.StatusCode == -1)
            {
                Debug.LogError("HTTPResponse error " + response.Error);
            }
            else
            {
                Debug.Log("response.GetResponseText()    == " + response.GetResponseText());
                // Debug.Log(AppBoot.instance);
                AppBoot.instance.AddCallFromAsync(() => { callBack(response.GetResponseText()); });
            }
        });

        client.ContentType = "application/x-www-form-urlencoded";
        string str = WWW.EscapeURL(data);

        client.AddPostData("data", str);
        client.Start();
    }