diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Config.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/Config.cs index 0411180..7e54ad1 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Config.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/Config.cs @@ -13,5 +13,6 @@ namespace LightReflectiveMirror public int UpdateHeartbeatInterval = 100; public bool UseEndpoint = false; public ushort EndpointPort = 6969; + public bool EndpointServerList = false; } } diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs index 5020b55..459db41 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/Endpoint.cs @@ -31,6 +31,20 @@ namespace LightReflectiveMirror.Endpoints string json = JsonConvert.SerializeObject(stats, Formatting.Indented); await context.Response.SendResponseAsync(json); } + + [RestRoute("Get", "/api/servers")] + public async Task ServerList(IHttpContext context) + { + if (Program.conf.EndpointServerList) + { + string json = JsonConvert.SerializeObject(Program.instance.GetRooms(), Formatting.Indented); + await context.Response.SendResponseAsync(json); + } + else + { + await context.Response.SendResponseAsync("Access Denied"); + } + } } public class EndpointServer diff --git a/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs b/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs index 6f39594..32c032b 100644 --- a/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs +++ b/ServerProject-DONT-IMPORT-INTO-UNITY/Room.cs @@ -4,6 +4,7 @@ using System.Text; namespace LightReflectiveMirror { + [Serializable] public class Room { public int serverId;