mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-06 22:50:30 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
69
server/FSO.Server.Api.Core/Controllers/Admin/AdminShardsController.cs
Executable file
69
server/FSO.Server.Api.Core/Controllers/Admin/AdminShardsController.cs
Executable file
|
@ -0,0 +1,69 @@
|
|||
using FSO.Server.Api.Core.Utils;
|
||||
using FSO.Server.Common;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
|
||||
namespace FSO.Server.Api.Core.Controllers.Admin
|
||||
{
|
||||
[EnableCors("AdminAppPolicy")]
|
||||
[Route("admin/shards")]
|
||||
[ApiController]
|
||||
public class AdminShardsController : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public IActionResult Get()
|
||||
{
|
||||
var api = Api.INSTANCE;
|
||||
api.DemandAdmin(Request);
|
||||
|
||||
using (var db = api.DAFactory.Get())
|
||||
{
|
||||
var shards = db.Shards.All();
|
||||
return ApiResponse.Json(HttpStatusCode.OK, shards);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("shutdown")]
|
||||
public IActionResult shutdown(ShutdownModel sd)
|
||||
{
|
||||
var api = Api.INSTANCE;
|
||||
api.DemandAdmin(Request);
|
||||
|
||||
ShutdownType type = ShutdownType.SHUTDOWN;
|
||||
if (sd.update) type = ShutdownType.UPDATE;
|
||||
else if (sd.restart) type = ShutdownType.RESTART;
|
||||
|
||||
api.RequestShutdown((uint)sd.timeout, type);
|
||||
|
||||
return ApiResponse.Json(HttpStatusCode.OK, true);
|
||||
}
|
||||
|
||||
[HttpPost("announce")]
|
||||
public IActionResult announce(AnnouncementModel an)
|
||||
{
|
||||
var api = Api.INSTANCE;
|
||||
api.DemandModerator(Request);
|
||||
|
||||
api.BroadcastMessage(an.sender, an.subject, an.message);
|
||||
|
||||
return ApiResponse.Json(HttpStatusCode.OK, true);
|
||||
}
|
||||
}
|
||||
|
||||
public class AnnouncementModel
|
||||
{
|
||||
public string sender;
|
||||
public string subject;
|
||||
public string message;
|
||||
public int[] shard_ids;
|
||||
}
|
||||
|
||||
public class ShutdownModel
|
||||
{
|
||||
public int timeout;
|
||||
public bool restart;
|
||||
public bool update;
|
||||
public int[] shard_ids;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue