From b181c29386cd4eb5698d93f5dd9b784ea747488a Mon Sep 17 00:00:00 2001 From: cxxpxr <60411087+cxxpxr@users.noreply.github.com> Date: Mon, 5 Apr 2021 19:22:24 -0400 Subject: [PATCH] Update Endpoint.cs --- .../LRM_LoadBalancer/Endpoint.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint.cs b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint.cs index 47392d3..5fe1486 100644 --- a/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint.cs +++ b/LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint.cs @@ -1,4 +1,4 @@ -using Grapevine; +using Grapevine; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -83,8 +83,12 @@ namespace LightReflectiveMirror.LoadBalancing if (lowest.Key.Address != "Dummy") { // ping server to ensure its online. - await Program.instance.ManualPingServer(lowest.Key.Address, lowest.Key.Port); - await context.Response.SendResponseAsync(JsonConvert.SerializeObject(lowest.Key)); + var chosenServer = await Program.instance.ManualPingServer(lowest.Key.Address, lowest.Key.EndpointPort); + + if(chosenServer.HasValue) + await context.Response.SendResponseAsync(JsonConvert.SerializeObject(lowest.Key)); + else + await context.Response.SendResponseAsync(HttpStatusCode.BadGateway); } else {