From 60d858166cd2e7cd6e4c771511d1ad74ba84772e Mon Sep 17 00:00:00 2001 From: "gu.martinm@gmail.com" Date: Sun, 23 Feb 2014 17:53:35 +0100 Subject: [PATCH] RemoteAgents Mono GTK Linux: TODO how to treat remote errors. --- .../GTKLinux/Model/CallRemoteProcedure.cs | 34 +++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs index f67879c..709543f 100644 --- a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs +++ b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs @@ -17,9 +17,9 @@ namespace Example.RemoteAgents.GTKLinux.Model async public Task callRemoteService(string uri, string method) { var postData = new POST(); - postData.Id = "2114567586433855105"; - postData.JSONrpc = "2.0"; - postData.Method = method; + postData.id = "2114567586433855105"; + postData.jsonrpc = "2.0"; + postData.method = method; string data = JsonConvert.SerializeObject(postData); HttpContent content = new StringContent(data, System.Text.Encoding.UTF8, "application/json-rpc"); @@ -32,7 +32,7 @@ namespace Example.RemoteAgents.GTKLinux.Model Task responseBytes = response.Content.ReadAsByteArrayAsync(); string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result); POSTResult postResult = JsonConvert.DeserializeObject>(responseString); - result = postResult.Result; + result = postResult.result; } return result; @@ -49,17 +49,31 @@ namespace Example.RemoteAgents.GTKLinux.Model private class POST { - public string Id { get; set; } - public string JSONrpc { get; set; } - public string Method { get; set; } + public string id { get; set; } + public string jsonrpc { get; set; } + public string method { get; set; } } private class POSTResult { - public string Id { get; set; } - public string JSONrpc { get; set; } - public TResult Result { get; set; } + public string id { get; set; } + public string jsonrpc { get; set; } + public TResult result { get; set; } + } + + // TODO: When error I receive from JSONRPC: {"jsonrpc":"2.0","id":"null","error":{"code":-32600,"message":"Invalid Request"}} + private class Error + { + public int code { get; set; } + public string message { get; set; } + } + + private class ERRORResult + { + public string jsonrpc { get; set; } + public string id { get; set; } + public Error error { get; set; } } } } -- 2.1.4