From 18bf369a1b40c2e596856a245f398c20c1146ee1 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Wed, 5 Jan 2022 15:24:15 +0000 Subject: [PATCH] Fixed Poll Response Poll response now works and accepts a list of responses from the server, in theory one of which should be the route response --- Controllers/RouteController.cs | 16 ++++++++++++---- Models/JSON/PollResponse.cs | 1 - 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Controllers/RouteController.cs b/Controllers/RouteController.cs index d73ddd3..0087324 100644 --- a/Controllers/RouteController.cs +++ b/Controllers/RouteController.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using System.Threading; using System.Collections.Generic; using System.Text; using System.Net.Http; @@ -115,6 +116,7 @@ namespace EFB.Controllers //Make calls to the server to fetch route bool collected = false; int count = 0; + string route; APIInterface API = new APIInterface(); @@ -123,19 +125,25 @@ namespace EFB.Controllers while (collected == false && count <= 5) { - count ++; - //Make Polling Request var pollingRequest = API.Put>($"https://api.autorouter.aero/v1.0/router/{user.Route.RouteID}/longpoll", headerData, null); ResponseModel> responsePoll = await pollingRequest; - //put request returns JSON that cannot be serialised by default - Console.WriteLine(responsePoll); + if (responsePoll.Result[count].Command == "solution") + { + collected = true; + route = responsePoll.Result[count].FlightPlan; + break; + } + + Thread.Sleep(5000); + count ++; } + return RedirectToAction("Index", "Route"); }else{ diff --git a/Models/JSON/PollResponse.cs b/Models/JSON/PollResponse.cs index 5169d10..3c353e9 100644 --- a/Models/JSON/PollResponse.cs +++ b/Models/JSON/PollResponse.cs @@ -6,7 +6,6 @@ using Newtonsoft.Json; namespace EFB.Models.JSON { - [JsonArray] public class PollResponse { [JsonProperty(PropertyName = "cmdname")]