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/Handlers/UserStatusHandler.cs

    r382 r387  
    11using AllocsFixes.JSON;
    2 using AllocsFixes.NetConnections.Servers.Web.API;
    3 using HttpListenerRequest = SpaceWizards.HttpListener.HttpListenerRequest;
    4 using HttpListenerResponse = SpaceWizards.HttpListener.HttpListenerResponse;
    52
    63namespace AllocsFixes.NetConnections.Servers.Web.Handlers {
     
    96                }
    107
    11                 public override void HandleRequest (string _requestPath, HttpListenerRequest _req, HttpListenerResponse _resp, WebConnection _con,
    12                         int _permissionLevel) {
     8                public override void HandleRequest (RequestContext _context) {
    139                        JSONObject result = new JSONObject ();
    1410
    15                         result.Add ("loggedin", new JSONBoolean (_con != null));
    16                         result.Add ("username", new JSONString (_con != null ? _con.UserId.ToString () : string.Empty));
     11                        result.Add ("loggedin", new JSONBoolean (_context.Connection != null));
     12                        result.Add ("username", new JSONString (_context.Connection != null ? _context.Connection.UserId.ToString () : string.Empty));
    1713
    1814                        JSONArray perms = new JSONArray ();
     
    2016                                JSONObject permObj = new JSONObject ();
    2117                                permObj.Add ("module", new JSONString (perm.module));
    22                                 permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _permissionLevel));
     18                                permObj.Add ("allowed", new JSONBoolean (perm.permissionLevel >= _context.PermissionLevel));
    2319                                perms.Add (permObj);
    2420                        }
     
    2622                        result.Add ("permissions", perms);
    2723
    28                         WebAPI.WriteJSON (_resp, result);
     24                        WebUtils.WriteJson (_context.Response, result);
    2925                }
    3026        }
Note: See TracChangeset for help on using the changeset viewer.