added server list endpoint
This commit is contained in:
parent
ec875235aa
commit
d73399109b
3 changed files with 16 additions and 0 deletions
|
|
@ -13,5 +13,6 @@ namespace LightReflectiveMirror
|
|||
public int UpdateHeartbeatInterval = 100;
|
||||
public bool UseEndpoint = false;
|
||||
public ushort EndpointPort = 6969;
|
||||
public bool EndpointServerList = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Text;
|
|||
|
||||
namespace LightReflectiveMirror
|
||||
{
|
||||
[Serializable]
|
||||
public class Room
|
||||
{
|
||||
public int serverId;
|
||||
|
|
|
|||
Loading…
Reference in a new issue