Update Endpoint.cs

This commit is contained in:
cxxpxr 2021-04-05 19:22:24 -04:00 committed by GitHub
parent 8a47b75c18
commit b181c29386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
using Grapevine; using Grapevine;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -83,8 +83,12 @@ namespace LightReflectiveMirror.LoadBalancing
if (lowest.Key.Address != "Dummy") if (lowest.Key.Address != "Dummy")
{ {
// ping server to ensure its online. // ping server to ensure its online.
await Program.instance.ManualPingServer(lowest.Key.Address, lowest.Key.Port); var chosenServer = await Program.instance.ManualPingServer(lowest.Key.Address, lowest.Key.EndpointPort);
if(chosenServer.HasValue)
await context.Response.SendResponseAsync(JsonConvert.SerializeObject(lowest.Key)); await context.Response.SendResponseAsync(JsonConvert.SerializeObject(lowest.Key));
else
await context.Response.SendResponseAsync(HttpStatusCode.BadGateway);
} }
else else
{ {