From: gu.martinm@gmail.com Date: Sat, 22 Feb 2014 15:03:35 +0000 (+0100) Subject: RemoteAgents Mono GTK Linux: check response status code. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=efa61dc23b2ab804e2a0a3c58d679cf5f110176c;p=CSharpForFun%2F.git RemoteAgents Mono GTK Linux: check response status code. --- diff --git a/Mono/RemoteAgents/GTKLinux/GTKLinux.csproj b/Mono/RemoteAgents/GTKLinux/GTKLinux.csproj index 21f6fec..ad9a7f6 100644 --- a/Mono/RemoteAgents/GTKLinux/GTKLinux.csproj +++ b/Mono/RemoteAgents/GTKLinux/GTKLinux.csproj @@ -57,6 +57,7 @@ monodevelop + True diff --git a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs index a8d633f..27572ea 100644 --- a/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs +++ b/Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs @@ -16,24 +16,25 @@ namespace Example.RemoteAgents.GTKLinux.Model async public Task callRemoteService(string uri, string method) { - POSTResult postResult; + TResult result = default(TResult); POST 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"); HttpResponseMessage response = await this.issueCall(uri, content); - //if (response.StatusCode == HttpStatusCode.OK) { + if (response.StatusCode == HttpStatusCode.OK) { Task responseBytes = response.Content.ReadAsByteArrayAsync(); string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result); - postResult = JsonConvert.DeserializeObject>(responseString); - //} + POSTResult postResult = JsonConvert.DeserializeObject>(responseString); + result = postResult.Result; + } - return postResult.result; + return result; } @@ -47,17 +48,17 @@ 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; } } } } diff --git a/Mono/RemoteAgents/GTKLinux/ViewModel/ViewModel.cs b/Mono/RemoteAgents/GTKLinux/ViewModel/ViewModel.cs index e6b7f30..cae493a 100644 --- a/Mono/RemoteAgents/GTKLinux/ViewModel/ViewModel.cs +++ b/Mono/RemoteAgents/GTKLinux/ViewModel/ViewModel.cs @@ -6,7 +6,7 @@ namespace Example.RemoteAgents.GTKLinux.ViewModel { public class ViewModelImpl { - private static readonly string uri = "gumartinm.name"; + private static readonly string uri = "http://gumartinm.name/spring-mainapp/CurrentDateService.json"; private static readonly CallRemoteProcedure remoteProcedure = new CallRemoteProcedure(); async public Task getCurrentDate()