Send() public method

public Send ( Action callback = null ) : void
callback Action
return void
Beispiel #1
0
 IEnumerator Download(Request request, DiskCacheOperation handle)
 {
     request.Send ();
     while (!request.isDone)
         yield return new WaitForEndOfFrame ();
     handle.isDone = true;
 }
Beispiel #2
0
    // Use this for initialization
    IEnumerator Start()
    {
        Hashtable data = new Hashtable();

        data.Add("title", "Game_02");
        data.Add("description", "Best game ever!");
        data.Add("currency", "1");
        data.Add("min_players", "2");
        data.Add("max_players", "2");
        data.Add("minimal_rate", "100");
        data.Add("prize_number", "1");


        /* UnityHTTP.Request someRequest = new UnityHTTP.Request("post", "http://someurl.com/some/post/handler", form);
         * someRequest.Send((request) => {
         *   // parse some JSON, for example:
         *   bool result = false;
         *   Hashtable thing = (Hashtable)JSON.JsonDecode(request.response.Text, ref result);
         *   if (!result)
         *   {
         *       Debug.LogWarning("Could not parse JSON response!");
         *       return;
         *   }
         * });*/
        UnityHTTP.Request someRequest = new UnityHTTP.Request("post", "http://dev.motivatedplay.com/api/games/create/", data);

        someRequest.SetHeader("Authorization", "Basic Y2hlbXNoZW5pazpOeWFzaGFfMjE=");
        someRequest.SetHeader("Content-Type", "application/json");
        someRequest.Send();

        while (!someRequest.isDone)
        {
            yield return(null);
        }

        // parse some JSON, for example:
        var thing = JSON.JsonDecode(someRequest.response.Text);

        yield return(null);
    }