RemoteAgents Mono GTK Linux: check response status code.
authorgu.martinm@gmail.com <gu.martinm@gmail.com>
Sat, 22 Feb 2014 15:03:35 +0000 (16:03 +0100)
committergu.martinm@gmail.com <gu.martinm@gmail.com>
Sat, 22 Feb 2014 15:03:35 +0000 (16:03 +0100)
Mono/RemoteAgents/GTKLinux/GTKLinux.csproj
Mono/RemoteAgents/GTKLinux/Model/CallRemoteProcedure.cs
Mono/RemoteAgents/GTKLinux/ViewModel/ViewModel.cs

index 21f6fec..ad9a7f6 100644 (file)
@@ -57,6 +57,7 @@
     </Reference>
     <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=c7439020c8fedf87">
       <Package>monodevelop</Package>
+      <Private>True</Private>
     </Reference>
   </ItemGroup>
   <ItemGroup>
index a8d633f..27572ea 100644 (file)
@@ -16,24 +16,25 @@ namespace Example.RemoteAgents.GTKLinux.Model
 
     async public Task<TResult> callRemoteService<TResult>(string uri, string method)
     {
-      POSTResult<TResult> 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<byte[]> responseBytes = response.Content.ReadAsByteArrayAsync();
         string responseString = System.Text.Encoding.UTF8.GetString(responseBytes.Result);
-        postResult = JsonConvert.DeserializeObject<POSTResult<TResult>>(responseString);
-      //}
+        POSTResult<TResult> postResult = JsonConvert.DeserializeObject<POSTResult<TResult>>(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<TResult>
     {
-      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; }
     }
   }
 }
index e6b7f30..cae493a 100644 (file)
@@ -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<string> getCurrentDate()