- Timestamp:
- Aug 6, 2022, 11:32:32 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/MapRendering/Web/API/GetPlayerList.cs
r383 r387 5 5 using AllocsFixes.JSON; 6 6 using AllocsFixes.PersistentData; 7 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;8 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;9 7 10 8 namespace AllocsFixes.NetConnections.Servers.Web.API { 11 public class GetPlayerList : WebAPI {9 public class GetPlayerList : AbsWebAPI { 12 10 private static readonly Regex numberFilterMatcher = 13 11 new Regex (@"^(>=|=>|>|<=|=<|<|==|=)?\s*([0-9]+(\.[0-9]*)?)$"); … … 17 15 #endif 18 16 19 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user, 20 int _permissionLevel) { 17 public override void HandleRequest (RequestContext _context) { 21 18 AdminTools admTools = GameManager.Instance.adminTools; 22 PlatformUserIdentifierAbs userId = _ user?.UserId;23 24 bool bViewAll = WebConnection.CanViewAllPlayers (_ permissionLevel);19 PlatformUserIdentifierAbs userId = _context.Connection?.UserId; 20 21 bool bViewAll = WebConnection.CanViewAllPlayers (_context.PermissionLevel); 25 22 26 23 // 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) 27 24 28 25 int rowsPerPage = 25; 29 if (_ req.QueryString ["rowsperpage"] != null) {30 int.TryParse (_ req.QueryString ["rowsperpage"], out rowsPerPage);26 if (_context.Request.QueryString ["rowsperpage"] != null) { 27 int.TryParse (_context.Request.QueryString ["rowsperpage"], out rowsPerPage); 31 28 } 32 29 33 30 int page = 0; 34 if (_ req.QueryString ["page"] != null) {35 int.TryParse (_ req.QueryString ["page"], out page);31 if (_context.Request.QueryString ["page"] != null) { 32 int.TryParse (_context.Request.QueryString ["page"], out page); 36 33 } 37 34 … … 83 80 IEnumerable<JSONObject> list = playerList; 84 81 85 foreach (string key in _ req.QueryString.AllKeys) {82 foreach (string key in _context.Request.QueryString.AllKeys) { 86 83 if (!string.IsNullOrEmpty (key) && key.StartsWith ("filter[")) { 87 84 string filterCol = key.Substring (key.IndexOf ('[') + 1); 88 85 filterCol = filterCol.Substring (0, filterCol.Length - 1); 89 string filterVal = _ req.QueryString.Get (key).Trim ();86 string filterVal = _context.Request.QueryString.Get (key).Trim (); 90 87 91 88 list = ExecuteFilter (list, filterCol, filterVal); … … 95 92 int totalAfterFilter = list.Count (); 96 93 97 foreach (string key in _ req.QueryString.AllKeys) {94 foreach (string key in _context.Request.QueryString.AllKeys) { 98 95 if (!string.IsNullOrEmpty (key) && key.StartsWith ("sort[")) { 99 96 string sortCol = key.Substring (key.IndexOf ('[') + 1); 100 97 sortCol = sortCol.Substring (0, sortCol.Length - 1); 101 string sortVal = _ req.QueryString.Get (key);98 string sortVal = _context.Request.QueryString.Get (key); 102 99 103 100 list = ExecuteSort (list, sortCol, sortVal == "0"); … … 120 117 result.Add ("players", playersJsResult); 121 118 122 W riteJSON (_resp, result);119 WebUtils.WriteJson (_context.Response, result); 123 120 } 124 121
Note:
See TracChangeset
for help on using the changeset viewer.