- Timestamp:
- Jul 28, 2023, 8:42:10 PM (16 months ago)
- Location:
- binary-improvements/MapRendering/API
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.