Changeset 279 for binary-improvements/MapRendering
- Timestamp:
- Jun 19, 2016, 1:52:31 PM (8 years ago)
- Location:
- binary-improvements/MapRendering
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Commands/webstat.cs
r230 r279 19 19 { 20 20 try { 21 SdtdConsole.Instance.Output ("Current handlers: " + AllocsFixes.NetConnections.Servers.Web.Web.currentHandlers + " - total: " + AllocsFixes.NetConnections.Servers.Web.Web.handlingCount); 21 int curHandlers = AllocsFixes.NetConnections.Servers.Web.Web.currentHandlers; 22 int totalHandlers = AllocsFixes.NetConnections.Servers.Web.Web.handlingCount; 23 long totalTime = AllocsFixes.NetConnections.Servers.Web.Web.totalHandlingTime; 24 SdtdConsole.Instance.Output ("Current Web handlers: " + curHandlers + " - total: " + totalHandlers); 25 SdtdConsole.Instance.Output (" - Total time: " + totalTime + " µs - average time: " + (totalTime / totalHandlers) + " µs"); 26 27 curHandlers = AllocsFixes.NetConnections.Servers.Web.WebCommandResult.currentHandlers; 28 totalHandlers = AllocsFixes.NetConnections.Servers.Web.WebCommandResult.handlingCount; 29 totalTime = AllocsFixes.NetConnections.Servers.Web.WebCommandResult.totalHandlingTime; 30 SdtdConsole.Instance.Output ("Current Web command handlers: " + curHandlers + " - total: " + totalHandlers); 31 SdtdConsole.Instance.Output (" - Total time: " + totalTime + " µs" + (totalHandlers > 0 ? " - average time: " + (totalTime / totalHandlers) + " µs" : "")); 22 32 } catch (Exception e) { 23 33 Log.Out ("Error in webstat.Run: " + e); -
binary-improvements/MapRendering/Web/API/ExecuteConsoleCommand.cs
r245 r279 16 16 } 17 17 18 string commandName = req.QueryString ["command"]; 18 string commandline = req.QueryString ["command"]; 19 string commandPart = commandline.Split (' ') [0]; 20 string argumentsPart = commandline.Substring (Math.Min (commandline.Length, commandPart.Length + 1)); 19 21 20 IConsoleCommand command = SdtdConsole.Instance.GetCommand (command Name);22 IConsoleCommand command = SdtdConsole.Instance.GetCommand (commandline); 21 23 22 24 if (command == null) { … … 36 38 // TODO: Execute command (store resp as IConsoleConnection instance to deliver response to the single client?) 37 39 38 // JSONObject result = new JSONObject (); 39 // result.Add ("claimsize", new JSONNumber (GamePrefs.GetInt (EnumGamePrefs.LandClaimSize))); 40 // 41 // JSONArray claimOwners = new JSONArray (); 42 // result.Add ("claimowners", claimOwners); 43 // 44 // Dictionary<Vector3i, PersistentPlayerData> d = GameManager.Instance.GetPersistentPlayerList ().m_lpBlockMap; 45 // if (d != null) { 46 // World w = GameManager.Instance.World; 47 // Dictionary<PersistentPlayerData, List<Vector3i>> owners = new Dictionary<PersistentPlayerData, List<Vector3i>> (); 48 // foreach (KeyValuePair<Vector3i, PersistentPlayerData> kvp in d) { 49 // if (steamid.Length == 0 || kvp.Value.PlayerId.Equals (steamid)) { 50 // if (!owners.ContainsKey (kvp.Value)) { 51 // owners.Add (kvp.Value, new List<Vector3i> ()); 52 // } 53 // owners [kvp.Value].Add (kvp.Key); 54 // } 55 // } 56 // 57 // foreach (KeyValuePair<PersistentPlayerData, List<Vector3i>> kvp in owners) { 58 // if (steamid.Length == 0 || kvp.Key.PlayerId.Equals (steamid)) { 59 // string curID = kvp.Key.PlayerId; 60 // bool isActive = w.IsLandProtectionValidForPlayer (kvp.Key); 61 // 62 // JSONObject owner = new JSONObject (); 63 // claimOwners.Add (owner); 64 // 65 // owner.Add ("steamid", new JSONString (curID)); 66 // owner.Add ("claimactive", new JSONBoolean (isActive)); 67 // 68 // JSONArray claims = new JSONArray (); 69 // owner.Add ("claims", claims); 70 // 71 // foreach (Vector3i v in kvp.Value) { 72 // JSONObject claim = new JSONObject (); 73 // claim.Add ("x", new JSONNumber (v.x)); 74 // claim.Add ("y", new JSONNumber (v.y)); 75 // claim.Add ("z", new JSONNumber (v.z)); 76 // 77 // claims.Add (claim); 78 // } 79 // } 80 // } 81 // } 82 // 83 // WriteJSON (resp, result); 40 resp.SendChunked = true; 41 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, resp); 42 SdtdConsole.Instance.ExecuteAsync (commandline, wcr); 43 } 44 45 public override int DefaultPermissionLevel () { 46 return 2000; 84 47 } 85 48 } -
binary-improvements/MapRendering/Web/API/GetStats.cs
r251 r279 26 26 WriteJSON (resp, result); 27 27 } 28 29 public override int DefaultPermissionLevel () { 30 return 2000; 31 } 28 32 } 29 33 } -
binary-improvements/MapRendering/Web/API/GetWebUIUpdates.cs
r251 r279 31 31 WriteJSON (resp, result); 32 32 } 33 34 public override int DefaultPermissionLevel () { 35 return 2000; 36 } 33 37 } 34 38 } -
binary-improvements/MapRendering/Web/API/WebAPI.cs
r244 r279 17 17 18 18 public abstract void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel); 19 20 public virtual int DefaultPermissionLevel () { 21 return 0; 22 } 19 23 } 20 24 } -
binary-improvements/MapRendering/Web/Handlers/ApiHandler.cs
r251 r279 40 40 private void addApi (string _apiName, WebAPI _api) { 41 41 apis.Add (_apiName, _api); 42 WebPermissions.Instance.AddKnownModule ("webapi." + _apiName );42 WebPermissions.Instance.AddKnownModule ("webapi." + _apiName, _api.DefaultPermissionLevel ()); 43 43 } 44 44 -
binary-improvements/MapRendering/Web/Handlers/PathHandler.cs
r244 r279 11 11 } 12 12 13 protected PathHandler (string _moduleName ) {13 protected PathHandler (string _moduleName, int _defaultPermissionLevel = 0) { 14 14 this.moduleName = _moduleName; 15 WebPermissions.Instance.AddKnownModule (_moduleName );15 WebPermissions.Instance.AddKnownModule (_moduleName, _defaultPermissionLevel); 16 16 } 17 17 -
binary-improvements/MapRendering/Web/Web.cs
r250 r279 20 20 public static int handlingCount = 0; 21 21 public static int currentHandlers = 0; 22 public static long totalHandlingTime = 0; 22 23 private string dataFolder; 23 24 private bool useStaticCache = false; … … 131 132 Interlocked.Increment (ref handlingCount); 132 133 Interlocked.Increment (ref currentHandlers); 134 MicroStopwatch msw = new MicroStopwatch (); 133 135 HttpListenerContext ctx = _listener.EndGetContext (result); 134 136 _listener.BeginGetContext (new AsyncCallback (HandleRequest), _listener); … … 136 138 HttpListenerRequest request = ctx.Request; 137 139 HttpListenerResponse response = ctx.Response; 140 response.SendChunked = false; 138 141 139 142 response.ProtocolVersion = new Version ("1.1"); … … 187 190 Log.Out ("Error in Web.HandleRequest(): " + e); 188 191 } finally { 189 if (ctx != null ) {192 if (ctx != null && !ctx.Response.SendChunked) { 190 193 ctx.Response.Close (); 191 194 } 195 msw.Stop (); 196 totalHandlingTime += msw.ElapsedMicroseconds; 197 Log.Out ("Web.HandleRequest(): Took {0} µs", msw.ElapsedMicroseconds); 192 198 Interlocked.Decrement (ref currentHandlers); 193 199 } -
binary-improvements/MapRendering/Web/WebPermissions.cs
r253 r279 96 96 } 97 97 98 public void AddKnownModule (string _module ) {98 public void AddKnownModule (string _module, int _defaultPermission) { 99 99 if (!string.IsNullOrEmpty (_module)) { 100 100 lock (this) { 101 101 if (!IsKnownModule( _module)) { 102 knownModules.Add (_module, new WebModulePermission (_module, 0));102 knownModules.Add (_module, new WebModulePermission (_module, _defaultPermission)); 103 103 } 104 if (_defaultPermission > 0 && !modules.ContainsKey (_module.ToLower ())) { 105 AddModulePermission (_module, _defaultPermission); 106 } 104 107 } 105 108 } -
binary-improvements/MapRendering/WebAndMapRendering.csproj
r277 r279 86 86 <Compile Include="Web\API\GetWebUIUpdates.cs" /> 87 87 <Compile Include="Web\API\GetServerInfo.cs" /> 88 <Compile Include="Web\API\GetPlayerList.cs" /> 89 <Compile Include="Web\WebCommandResult.cs" /> 90 <Compile Include="Web\API\GetAllowedCommands.cs" /> 88 91 </ItemGroup> 89 92 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Note:
See TracChangeset
for help on using the changeset viewer.