Beispiel #1
0
        public void sendRequestHttpPost(string url, JsonObject mJsonObject, Dictionary <String, String> headers, Callback mCallbackPost)
        {
            var client = new RestClient(url);

            // client.Authenticator = new HttpBasicAuthenticator(username, password);
            Console.Write("URL? " + url);
            var request = new RestRequest();

            Console.WriteLine("sending " + mJsonObject.ToString());
            request.AddJsonBody(mJsonObject.ToString());
            client.PostAsync(request, (IRestResponse arg1, RestRequestAsyncHandle arg2) =>
            {
                var o = JsonObject.Parse(arg1.Content);
                if (mCallbackPost != null)
                {
                    JsonObject obj = (System.Json.JsonObject)o;
                    Console.WriteLine("received2 " + obj.ToString());
                    if (handleUnregistered(obj, getHandler(), mCallbackPost))
                    {
                        return;
                    }
                    else
                    {
                        Console.WriteLine("Handle normally");
                        mCallbackPost.onResponse(obj);
                    }
                }
            });
        }