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
This commit is contained in:
parent
b61b767194
commit
18bf369a1b
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@ -115,6 +116,7 @@ namespace EFB.Controllers
|
|||||||
//Make calls to the server to fetch route
|
//Make calls to the server to fetch route
|
||||||
bool collected = false;
|
bool collected = false;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
string route;
|
||||||
|
|
||||||
APIInterface API = new APIInterface();
|
APIInterface API = new APIInterface();
|
||||||
|
|
||||||
@ -123,19 +125,25 @@ namespace EFB.Controllers
|
|||||||
|
|
||||||
while (collected == false && count <= 5)
|
while (collected == false && count <= 5)
|
||||||
{
|
{
|
||||||
count ++;
|
|
||||||
|
|
||||||
//Make Polling Request
|
//Make Polling Request
|
||||||
var pollingRequest = API.Put<List<PollResponse>>($"https://api.autorouter.aero/v1.0/router/{user.Route.RouteID}/longpoll", headerData, null);
|
var pollingRequest = API.Put<List<PollResponse>>($"https://api.autorouter.aero/v1.0/router/{user.Route.RouteID}/longpoll", headerData, null);
|
||||||
|
|
||||||
ResponseModel<List<PollResponse>> responsePoll = await pollingRequest;
|
ResponseModel<List<PollResponse>> responsePoll = await pollingRequest;
|
||||||
|
|
||||||
|
|
||||||
//put request returns JSON that cannot be serialised by default
|
if (responsePoll.Result[count].Command == "solution")
|
||||||
Console.WriteLine(responsePoll);
|
{
|
||||||
|
collected = true;
|
||||||
|
route = responsePoll.Result[count].FlightPlan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
count ++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return RedirectToAction("Index", "Route");
|
return RedirectToAction("Index", "Route");
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -6,7 +6,6 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace EFB.Models.JSON
|
namespace EFB.Models.JSON
|
||||||
{
|
{
|
||||||
[JsonArray]
|
|
||||||
public class PollResponse
|
public class PollResponse
|
||||||
{
|
{
|
||||||
[JsonProperty(PropertyName = "cmdname")]
|
[JsonProperty(PropertyName = "cmdname")]
|
||||||
|
Loading…
Reference in New Issue
Block a user