- Timestamp:
- Aug 6, 2022, 11:32:32 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/MapRendering/Web/API/GetPlayerInventory.cs
r382 r387 4 4 using AllocsFixes.PersistentData; 5 5 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest; 6 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;7 6 8 7 namespace AllocsFixes.NetConnections.Servers.Web.API { 9 public class GetPlayerInventory : WebAPI { 10 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, 11 WebConnection _user, int _permissionLevel) { 12 if (_req.QueryString ["userid"] == null) { 13 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 14 Web.SetResponseTextContent (_resp, "No user id given"); 8 public class GetPlayerInventory : AbsWebAPI { 9 public override void HandleRequest (RequestContext _context) { 10 if (_context.Request.QueryString ["userid"] == null) { 11 WebUtils.WriteText (_context.Response, "No user id given", HttpStatusCode.BadRequest); 15 12 return; 16 13 } 17 14 18 string userIdString = _ req.QueryString ["userid"];15 string userIdString = _context.Request.QueryString ["userid"]; 19 16 if (!PlatformUserIdentifierAbs.TryFromCombinedString (userIdString, out PlatformUserIdentifierAbs userId)) { 20 _resp.StatusCode = (int) HttpStatusCode.BadRequest; 21 Web.SetResponseTextContent (_resp, "Invalid user id given"); 17 WebUtils.WriteText (_context.Response, "Invalid user id given", HttpStatusCode.BadRequest); 22 18 return; 23 19 } … … 25 21 Player p = PersistentContainer.Instance.Players [userId, false]; 26 22 if (p == null) { 27 _resp.StatusCode = (int) HttpStatusCode.NotFound; 28 Web.SetResponseTextContent (_resp, "Unknown user id given"); 23 WebUtils.WriteText (_context.Response, "Unknown user id given", HttpStatusCode.NotFound); 29 24 return; 30 25 } 31 26 32 GetInventoryArguments (_ req, out bool showIconColor, out bool showIconName);27 GetInventoryArguments (_context.Request, out bool showIconColor, out bool showIconName); 33 28 34 29 JSONObject result = DoPlayer (userIdString, p, showIconColor, showIconName); 35 30 36 W riteJSON (_resp, result);31 WebUtils.WriteJson (_context.Response, result); 37 32 } 38 33
Note:
See TracChangeset
for help on using the changeset viewer.