Changeset 454 for binary-improvements/MapRendering/API
- Timestamp:
- Jul 28, 2023, 8:42:10 PM (17 months ago)
- Location:
- binary-improvements/MapRendering/API
- Files:
-
- 1 added
- 14 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/API/ExecuteConsoleCommand.cs
r453 r454 1 1 using System; 2 2 using System.Net; 3 using Webserver; 4 using Webserver.WebAPI; 5 using WebCommandResult = AllocsFixes.NetConnections.Servers.Web.WebCommandResult; 3 6 4 namespace AllocsFixes.NetConnections.Servers.Web.API { 5 public class ExecuteConsoleCommand : WebAPI { 6 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 7 int _permissionLevel) { 8 if (string.IsNullOrEmpty (_req.QueryString ["command"])) { 9 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 10 Web.SetResponseTextContent (_resp, "No command given"); 7 namespace AllocsFixes.WebAPIs { 8 public class ExecuteConsoleCommand : AbsWebAPI { 9 public override void HandleRequest (RequestContext _context) { 10 if (string.IsNullOrEmpty (_context.Request.QueryString ["command"])) { 11 WebUtils.WriteText (_context.Response, "No command given", HttpStatusCode.BadRequest); 11 12 return; 12 13 } 13 14 14 15 WebCommandResult.ResultType responseType = 15 _ req.QueryString ["raw"] != null16 _context.Request.QueryString ["raw"] != null 16 17 ? WebCommandResult.ResultType.Raw 17 : (_ req.QueryString ["simple"] != null18 : (_context.Request.QueryString ["simple"] != null 18 19 ? WebCommandResult.ResultType.ResultOnly 19 20 : WebCommandResult.ResultType.Full); 20 21 21 string commandline = _ req.QueryString ["command"];22 string commandline = _context.Request.QueryString ["command"]; 22 23 string commandPart = commandline.Split (' ') [0]; 23 24 string argumentsPart = commandline.Substring (Math.Min (commandline.Length, commandPart.Length + 1)); … … 26 27 27 28 if (command == null) { 28 _resp.StatusCode = (int) HttpStatusCode.NotFound; 29 Web.SetResponseTextContent (_resp, "Unknown command"); 29 WebUtils.WriteText (_context.Response, "Unknown command", HttpStatusCode.NotFound); 30 30 return; 31 31 } … … 33 33 int commandPermissionLevel = GameManager.Instance.adminTools.Commands.GetCommandPermissionLevel (command.GetCommands ()); 34 34 35 if (_permissionLevel > commandPermissionLevel) { 36 _resp.StatusCode = (int) HttpStatusCode.Forbidden; 37 Web.SetResponseTextContent (_resp, "You are not allowed to execute this command"); 35 if (_context.PermissionLevel > commandPermissionLevel) { 36 WebUtils.WriteText (_context.Response, "You are not allowed to execute this command", HttpStatusCode.Forbidden); 38 37 return; 39 38 } 40 39 41 _ resp.SendChunked = true;42 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, _ resp);40 _context.Response.SendChunked = true; 41 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, _context); 43 42 SdtdConsole.Instance.ExecuteAsync (commandline, wcr); 44 43 } -
binary-improvements/MapRendering/API/GetAllowedCommands.cs
r453 r454 1 using System.Net;2 1 using AllocsFixes.JSON; 2 using Webserver; 3 using Webserver.WebAPI; 3 4 4 namespace AllocsFixes.NetConnections.Servers.Web.API { 5 public class GetAllowedCommands : WebAPI { 6 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 7 int _permissionLevel) { 5 namespace AllocsFixes.WebAPIs { 6 public class GetAllowedCommands : AbsWebAPI { 7 public override void HandleRequest (RequestContext _context) { 8 8 JSONObject result = new JSONObject (); 9 9 JSONArray entries = new JSONArray (); 10 10 foreach (IConsoleCommand cc in SdtdConsole.Instance.GetCommands ()) { 11 11 int commandPermissionLevel = GameManager.Instance.adminTools.Commands.GetCommandPermissionLevel (cc.GetCommands ()); 12 if (_ permissionLevel <= commandPermissionLevel) {12 if (_context.PermissionLevel <= commandPermissionLevel) { 13 13 string cmd = string.Empty; 14 14 foreach (string s in cc.GetCommands ()) { … … 28 28 result.Add ("commands", entries); 29 29 30 WriteJSON (_resp, result);30 LegacyApiHelper.WriteJSON (_context.Response, result); 31 31 } 32 32 -
binary-improvements/MapRendering/API/GetAnimalsLocation.cs
r453 r454 1 1 using System.Collections.Generic; 2 using System.Net;3 2 using AllocsFixes.JSON; 4 3 using AllocsFixes.LiveData; 4 using Webserver; 5 using Webserver.WebAPI; 5 6 6 namespace AllocsFixes. NetConnections.Servers.Web.API{7 internal class GetAnimalsLocation : WebAPI {7 namespace AllocsFixes.WebAPIs { 8 internal class GetAnimalsLocation : AbsWebAPI { 8 9 private readonly List<EntityAnimal> animals = new List<EntityAnimal> (); 9 10 10 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 11 int _permissionLevel) { 11 public override void HandleRequest (RequestContext _context) { 12 12 JSONArray animalsJsResult = new JSONArray (); 13 13 … … 36 36 } 37 37 38 WriteJSON (_resp, animalsJsResult);38 LegacyApiHelper.WriteJSON (_context.Response, animalsJsResult); 39 39 } 40 40 } -
binary-improvements/MapRendering/API/GetHostileLocation.cs
r453 r454 1 1 using System.Collections.Generic; 2 using System.Net;3 2 using AllocsFixes.JSON; 4 3 using AllocsFixes.LiveData; 4 using Webserver; 5 using Webserver.WebAPI; 5 6 6 namespace AllocsFixes. NetConnections.Servers.Web.API{7 internal class GetHostileLocation : WebAPI {7 namespace AllocsFixes.WebAPIs { 8 internal class GetHostileLocation : AbsWebAPI { 8 9 private readonly List<EntityEnemy> enemies = new List<EntityEnemy> (); 9 10 10 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 11 int _permissionLevel) { 11 public override void HandleRequest (RequestContext _context) { 12 12 JSONArray hostilesJsResult = new JSONArray (); 13 13 … … 36 36 } 37 37 38 WriteJSON (_resp, hostilesJsResult);38 LegacyApiHelper.WriteJSON (_context.Response, hostilesJsResult); 39 39 } 40 40 } -
binary-improvements/MapRendering/API/GetLandClaims.cs
r453 r454 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using Webserver; 6 using Webserver.Permissions; 7 using Webserver.WebAPI; 5 8 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 public class GetLandClaims : WebAPI { 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 int _permissionLevel) { 9 namespace AllocsFixes.WebAPIs { 10 public class GetLandClaims : AbsWebAPI { 11 public override void HandleRequest (RequestContext _context) { 10 12 PlatformUserIdentifierAbs requestedUserId = null; 11 if (_req.QueryString ["userid"] != null) { 12 if (!PlatformUserIdentifierAbs.TryFromCombinedString (_req.QueryString ["userid"], out requestedUserId)) { 13 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 14 Web.SetResponseTextContent (_resp, "Invalid user id given"); 13 if (_context.Request.QueryString ["userid"] != null) { 14 if (!PlatformUserIdentifierAbs.TryFromCombinedString (_context.Request.QueryString ["userid"], out requestedUserId)) { 15 WebUtils.WriteText (_context.Response, "Invalid user id given", HttpStatusCode.BadRequest); 15 16 return; 16 17 } … … 18 19 19 20 // default user, cheap way to avoid 'null reference exception' 20 PlatformUserIdentifierAbs userId = _ user?.UserId;21 PlatformUserIdentifierAbs userId = _context.Connection?.UserId; 21 22 22 bool bViewAll = WebConnection.CanViewAllClaims (_permissionLevel);23 bool bViewAll = PermissionUtils.CanViewAllClaims (_context.PermissionLevel); 23 24 24 25 JSONObject result = new JSONObject (); … … 73 74 } 74 75 75 WriteJSON (_resp, result);76 LegacyApiHelper.WriteJSON (_context.Response, result); 76 77 } 77 78 } -
binary-improvements/MapRendering/API/GetLog.cs
r453 r454 1 1 using System.Collections.Generic; 2 using System.Net;3 2 using AllocsFixes.JSON; 3 using Webserver; 4 using Webserver.WebAPI; 4 5 5 namespace AllocsFixes. NetConnections.Servers.Web.API{6 public class GetLog : WebAPI {6 namespace AllocsFixes.WebAPIs { 7 public class GetLog : AbsWebAPI { 7 8 private const int MAX_COUNT = 1000; 8 9 9 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 10 int _permissionLevel) { 11 int count, firstLine, lastLine; 12 13 if (_req.QueryString ["count"] == null || !int.TryParse (_req.QueryString ["count"], out count)) { 10 public override void HandleRequest (RequestContext _context) { 11 if (_context.Request.QueryString ["count"] == null || !int.TryParse (_context.Request.QueryString ["count"], out var count)) { 14 12 count = 50; 15 13 } … … 27 25 } 28 26 29 if (_ req.QueryString ["firstLine"] == null || !int.TryParse (_req.QueryString ["firstLine"], outfirstLine)) {27 if (_context.Request.QueryString ["firstLine"] == null || !int.TryParse (_context.Request.QueryString ["firstLine"], out var firstLine)) { 30 28 if (count > 0) { 31 29 firstLine = LogBuffer.Instance.OldestLine; … … 37 35 JSONObject result = new JSONObject (); 38 36 39 List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, count, out lastLine);37 List<LogBuffer.LogEntry> logEntries = LogBuffer.Instance.GetRange (ref firstLine, count, out var lastLine); 40 38 41 39 JSONArray entries = new JSONArray (); 42 40 foreach (LogBuffer.LogEntry logEntry in logEntries) { 43 41 JSONObject entry = new JSONObject (); 44 entry.Add ("date", new JSONString (logEntry.date)); 45 entry.Add ("time", new JSONString (logEntry.time)); 46 entry.Add ("uptime", new JSONString (logEntry.uptime)); 47 entry.Add ("msg", new JSONString (logEntry.message)); 48 entry.Add ("trace", new JSONString (logEntry.trace)); 49 entry.Add ("type", new JSONString (logEntry.type.ToStringCached ())); 42 var logEntryTimestamp = logEntry.Timestamp; 43 entry.Add ("date", new JSONString ($"{logEntryTimestamp.Year:0000}-{logEntryTimestamp.Month:00}-{logEntryTimestamp.Day:00}")); 44 entry.Add ("time", new JSONString ($"{logEntryTimestamp.Hour:00}:{logEntryTimestamp.Minute:00}:{logEntryTimestamp.Second:00}")); 45 entry.Add ("uptime", new JSONString (logEntry.Uptime.ToString())); 46 entry.Add ("msg", new JSONString (logEntry.Message)); 47 entry.Add ("trace", new JSONString (logEntry.Trace)); 48 entry.Add ("type", new JSONString (logEntry.Type.ToStringCached ())); 50 49 entries.Add (entry); 51 50 } … … 55 54 result.Add ("entries", entries); 56 55 57 WriteJSON (_resp, result);56 LegacyApiHelper.WriteJSON (_context.Response, result); 58 57 } 59 58 } -
binary-improvements/MapRendering/API/GetPlayerInventories.cs
r453 r454 1 1 using System.Collections.Generic; 2 using System.Net;3 2 using AllocsFixes.JSON; 4 3 using AllocsFixes.PersistentData; 4 using Webserver; 5 using Webserver.WebAPI; 5 6 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 public class GetPlayerInventories : WebAPI { 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 int _permissionLevel) { 10 GetPlayerInventory.GetInventoryArguments (_req, out bool showIconColor, out bool showIconName); 7 namespace AllocsFixes.WebAPIs { 8 public class GetPlayerInventories : AbsWebAPI { 9 public override void HandleRequest (RequestContext _context) { 10 GetPlayerInventory.GetInventoryArguments (_context, out bool showIconColor, out bool showIconName); 11 11 12 12 JSONArray AllInventoriesResult = new JSONArray (); … … 24 24 } 25 25 26 WriteJSON (_resp, AllInventoriesResult);26 LegacyApiHelper.WriteJSON (_context.Response, AllInventoriesResult); 27 27 } 28 28 } -
binary-improvements/MapRendering/API/GetPlayerInventory.cs
r453 r454 3 3 using AllocsFixes.JSON; 4 4 using AllocsFixes.PersistentData; 5 using Webserver; 6 using Webserver.WebAPI; 5 7 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 public class GetPlayerInventory : WebAPI { 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 int _permissionLevel) { 10 if (_req.QueryString ["userid"] == null) { 11 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 12 Web.SetResponseTextContent (_resp, "No user id given"); 8 namespace AllocsFixes.WebAPIs { 9 public class GetPlayerInventory : AbsWebAPI { 10 public override void HandleRequest (RequestContext _context) { 11 if (_context.Request.QueryString ["userid"] == null) { 12 WebUtils.WriteText (_context.Response, "No user id given", HttpStatusCode.BadRequest); 13 13 return; 14 14 } 15 15 16 string userIdString = _ req.QueryString ["userid"];16 string userIdString = _context.Request.QueryString ["userid"]; 17 17 if (!PlatformUserIdentifierAbs.TryFromCombinedString (userIdString, out PlatformUserIdentifierAbs userId)) { 18 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 19 Web.SetResponseTextContent (_resp, "Invalid user id given"); 18 WebUtils.WriteText (_context.Response, "Invalid user id given", HttpStatusCode.BadRequest); 20 19 return; 21 20 } … … 23 22 Player p = PersistentContainer.Instance.Players.GetByUserId (userId); 24 23 if (p == null) { 25 _resp.StatusCode = (int) HttpStatusCode.NotFound; 26 Web.SetResponseTextContent (_resp, "Unknown user id given"); 24 WebUtils.WriteText (_context.Response, "Unknown user id given", HttpStatusCode.NotFound); 27 25 return; 28 26 } 29 27 30 GetInventoryArguments (_ req, out bool showIconColor, out bool showIconName);28 GetInventoryArguments (_context, out bool showIconColor, out bool showIconName); 31 29 32 30 JSONObject result = DoPlayer (p, showIconColor, showIconName); 33 31 34 WriteJSON (_resp, result);32 LegacyApiHelper.WriteJSON (_context.Response, result); 35 33 } 36 34 37 internal static void GetInventoryArguments ( HttpListenerRequest _req, out bool _showIconColor, out bool _showIconName) {38 if (_ req.QueryString ["showiconcolor"] == null || !bool.TryParse (_req.QueryString ["showiconcolor"], out _showIconColor)) {35 internal static void GetInventoryArguments (RequestContext _context, out bool _showIconColor, out bool _showIconName) { 36 if (_context.Request.QueryString ["showiconcolor"] == null || !bool.TryParse (_context.Request.QueryString ["showiconcolor"], out _showIconColor)) { 39 37 _showIconColor = true; 40 38 } 41 39 42 if (_ req.QueryString ["showiconname"] == null || !bool.TryParse (_req.QueryString ["showiconname"], out _showIconName)) {40 if (_context.Request.QueryString ["showiconname"] == null || !bool.TryParse (_context.Request.QueryString ["showiconname"], out _showIconName)) { 43 41 _showIconName = true; 44 42 } -
binary-improvements/MapRendering/API/GetPlayerList.cs
r453 r454 2 2 using System.Collections.Generic; 3 3 using System.Linq; 4 using System.Net;5 4 using System.Text.RegularExpressions; 6 5 using AllocsFixes.JSON; 7 6 using AllocsFixes.PersistentData; 8 9 namespace AllocsFixes.NetConnections.Servers.Web.API { 10 public class GetPlayerList : WebAPI { 7 using Webserver; 8 using Webserver.Permissions; 9 using Webserver.WebAPI; 10 11 namespace AllocsFixes.WebAPIs { 12 public class GetPlayerList : AbsWebAPI { 11 13 private static readonly Regex numberFilterMatcher = 12 14 new Regex (@"^(>=|=>|>|<=|=<|<|==|=)?\s*([0-9]+(\.[0-9]*)?)$"); … … 16 18 #endif 17 19 18 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 19 int _permissionLevel) { 20 public override void HandleRequest (RequestContext _context) { 20 21 AdminTools admTools = GameManager.Instance.adminTools; 21 PlatformUserIdentifierAbs userId = _ user?.UserId;22 23 bool bViewAll = WebConnection.CanViewAllPlayers (_permissionLevel);22 PlatformUserIdentifierAbs userId = _context.Connection?.UserId; 23 24 bool bViewAll = PermissionUtils.CanViewAllPlayers (_context.PermissionLevel); 24 25 25 26 // TODO: Sort (and filter?) prior to converting to JSON ... hard as how to get the correct column's data? (i.e. column name matches JSON object field names, not source data) 26 27 27 28 int rowsPerPage = 25; 28 if (_ req.QueryString ["rowsperpage"] != null) {29 int.TryParse (_ req.QueryString ["rowsperpage"], out rowsPerPage);29 if (_context.Request.QueryString ["rowsperpage"] != null) { 30 int.TryParse (_context.Request.QueryString ["rowsperpage"], out rowsPerPage); 30 31 } 31 32 32 33 int page = 0; 33 if (_ req.QueryString ["page"] != null) {34 int.TryParse (_ req.QueryString ["page"], out page);34 if (_context.Request.QueryString ["page"] != null) { 35 int.TryParse (_context.Request.QueryString ["page"], out page); 35 36 } 36 37 … … 83 84 IEnumerable<JSONObject> list = playerList; 84 85 85 foreach (string key in _ req.QueryString.AllKeys) {86 foreach (string key in _context.Request.QueryString.AllKeys) { 86 87 if (!string.IsNullOrEmpty (key) && key.StartsWith ("filter[")) { 87 88 string filterCol = key.Substring (key.IndexOf ('[') + 1); 88 89 filterCol = filterCol.Substring (0, filterCol.Length - 1); 89 string filterVal = _ req.QueryString.Get (key).Trim ();90 string filterVal = _context.Request.QueryString.Get (key).Trim (); 90 91 91 92 list = ExecuteFilter (list, filterCol, filterVal); … … 95 96 int totalAfterFilter = list.Count (); 96 97 97 foreach (string key in _ req.QueryString.AllKeys) {98 foreach (string key in _context.Request.QueryString.AllKeys) { 98 99 if (!string.IsNullOrEmpty (key) && key.StartsWith ("sort[")) { 99 100 string sortCol = key.Substring (key.IndexOf ('[') + 1); 100 101 sortCol = sortCol.Substring (0, sortCol.Length - 1); 101 string sortVal = _ req.QueryString.Get (key);102 string sortVal = _context.Request.QueryString.Get (key); 102 103 103 104 list = ExecuteSort (list, sortCol, sortVal == "0"); … … 120 121 result.Add ("players", playersJsResult); 121 122 122 WriteJSON (_resp, result);123 LegacyApiHelper.WriteJSON (_context.Response, result); 123 124 } 124 125 -
binary-improvements/MapRendering/API/GetPlayersLocation.cs
r453 r454 1 1 using System.Collections.Generic; 2 using System.Net;3 2 using AllocsFixes.JSON; 4 3 using AllocsFixes.PersistentData; 4 using Webserver; 5 using Webserver.Permissions; 6 using Webserver.WebAPI; 5 7 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 public class GetPlayersLocation : WebAPI { 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 int _permissionLevel) { 8 namespace AllocsFixes.WebAPIs { 9 public class GetPlayersLocation : AbsWebAPI { 10 public override void HandleRequest (RequestContext _context) { 10 11 AdminTools admTools = GameManager.Instance.adminTools; 11 PlatformUserIdentifierAbs userId = _ user?.UserId;12 PlatformUserIdentifierAbs userId = _context.Connection?.UserId; 12 13 13 14 bool listOffline = false; 14 if (_ req.QueryString ["offline"] != null) {15 bool.TryParse (_ req.QueryString ["offline"], out listOffline);15 if (_context.Request.QueryString ["offline"] != null) { 16 bool.TryParse (_context.Request.QueryString ["offline"], out listOffline); 16 17 } 17 18 18 bool bViewAll = WebConnection.CanViewAllPlayers (_permissionLevel);19 bool bViewAll = PermissionUtils.CanViewAllPlayers (_context.PermissionLevel); 19 20 20 21 JSONArray playersJsResult = new JSONArray (); … … 57 58 } 58 59 59 WriteJSON (_resp, playersJsResult);60 LegacyApiHelper.WriteJSON (_context.Response, playersJsResult); 60 61 } 61 62 } -
binary-improvements/MapRendering/API/GetPlayersOnline.cs
r453 r454 1 1 using System.Collections.Generic; 2 using System.Net;3 2 using AllocsFixes.JSON; 4 3 using AllocsFixes.PersistentData; 4 using Webserver; 5 using Webserver.WebAPI; 5 6 6 namespace AllocsFixes.NetConnections.Servers.Web.API { 7 public class GetPlayersOnline : WebAPI { 8 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 9 int _permissionLevel) { 7 namespace AllocsFixes.WebAPIs { 8 public class GetPlayersOnline : AbsWebAPI { 9 public override void HandleRequest (RequestContext _context) { 10 10 JSONArray players = new JSONArray (); 11 11 … … 44 44 } 45 45 46 WriteJSON (_resp, players);46 LegacyApiHelper.WriteJSON (_context.Response, players); 47 47 } 48 48 } -
binary-improvements/MapRendering/API/GetServerInfo.cs
r453 r454 1 1 using System; 2 using System.Net;3 2 using AllocsFixes.JSON; 3 using Webserver; 4 using Webserver.WebAPI; 4 5 5 namespace AllocsFixes.NetConnections.Servers.Web.API { 6 public class GetServerInfo : WebAPI { 7 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 8 int _permissionLevel) { 6 namespace AllocsFixes.WebAPIs { 7 public class GetServerInfo : AbsWebAPI { 8 public override void HandleRequest (RequestContext _context) { 9 9 JSONObject serverInfo = new JSONObject (); 10 10 … … 42 42 43 43 44 WriteJSON (_resp, serverInfo);44 LegacyApiHelper.WriteJSON (_context.Response, serverInfo); 45 45 } 46 46 } -
binary-improvements/MapRendering/API/GetStats.cs
r453 r454 1 using System.Net;2 1 using AllocsFixes.JSON; 3 2 using AllocsFixes.LiveData; 3 using Webserver; 4 using Webserver.WebAPI; 4 5 5 namespace AllocsFixes.NetConnections.Servers.Web.API { 6 public class GetStats : WebAPI { 7 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 8 int _permissionLevel) { 6 namespace AllocsFixes.WebAPIs { 7 public class GetStats : AbsWebAPI { 8 public override void HandleRequest (RequestContext _context) { 9 9 JSONObject result = new JSONObject (); 10 10 … … 19 19 result.Add ("animals", new JSONNumber (Animals.Instance.GetCount ())); 20 20 21 WriteJSON (_resp, result);21 LegacyApiHelper.WriteJSON (_context.Response, result); 22 22 } 23 23 -
binary-improvements/MapRendering/API/GetWebUIUpdates.cs
r453 r454 1 using System.Net;2 1 using AllocsFixes.JSON; 3 2 using AllocsFixes.LiveData; 3 using Webserver; 4 using Webserver.WebAPI; 4 5 5 namespace AllocsFixes.NetConnections.Servers.Web.API { 6 public class GetWebUIUpdates : WebAPI { 7 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 8 int _permissionLevel) { 6 namespace AllocsFixes.WebAPIs { 7 public class GetWebUIUpdates : AbsWebAPI { 8 public override void HandleRequest (RequestContext _context) { 9 9 int latestLine; 10 if (_ req.QueryString ["latestLine"] == null ||11 !int.TryParse (_ req.QueryString ["latestLine"], out latestLine)) {10 if (_context.Request.QueryString ["latestLine"] == null || 11 !int.TryParse (_context.Request.QueryString ["latestLine"], out latestLine)) { 12 12 latestLine = 0; 13 13 } … … 27 27 result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine)); 28 28 29 WriteJSON (_resp, result);29 LegacyApiHelper.WriteJSON (_context.Response, result); 30 30 } 31 31
Note:
See TracChangeset
for help on using the changeset viewer.