Ignore:
Timestamp:
Aug 6, 2022, 11:32:32 PM (2 years ago)
Author:
alloc
Message:

Big refactoring in Web to pass around a Context instead of a bunch of individual arguments all the time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements2/MapRendering/Web/API/GetPlayersLocation.cs

    r383 r387  
    22using AllocsFixes.JSON;
    33using AllocsFixes.PersistentData;
    4 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
    5 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
    64
    75namespace AllocsFixes.NetConnections.Servers.Web.API {
    8         public class GetPlayersLocation : WebAPI {
    9                 public override void HandleRequest (HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _user,
    10                         int _permissionLevel) {
     6        public class GetPlayersLocation : AbsWebAPI {
     7                public override void HandleRequest (RequestContext _context) {
    118                        AdminTools admTools = GameManager.Instance.adminTools;
    12                         PlatformUserIdentifierAbs userId = _user?.UserId;
     9                        PlatformUserIdentifierAbs userId = _context.Connection?.UserId;
    1310
    1411                        bool listOffline = false;
    15                         if (_req.QueryString ["offline"] != null) {
    16                                 bool.TryParse (_req.QueryString ["offline"], out listOffline);
     12                        if (_context.Request.QueryString ["offline"] != null) {
     13                                bool.TryParse (_context.Request.QueryString ["offline"], out listOffline);
    1714                        }
    1815
    19                         bool bViewAll = WebConnection.CanViewAllPlayers (_permissionLevel);
     16                        bool bViewAll = WebConnection.CanViewAllPlayers (_context.PermissionLevel);
    2017
    2118                        JSONArray playersJsResult = new JSONArray ();
     
    5754                        }
    5855
    59                         WriteJSON (_resp, playersJsResult);
     56                        WebUtils.WriteJson (_context.Response, playersJsResult);
    6057                }
    6158        }
Note: See TracChangeset for help on using the changeset viewer.