Changeset 306 for binary-improvements/MapRendering/Web/API
- Timestamp:
- Aug 2, 2017, 6:46:15 PM (7 years ago)
- Location:
- binary-improvements/MapRendering/Web/API
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/ExecuteConsoleCommand.cs
r279 r306 15 15 return; 16 16 } 17 18 WebCommandResult.ResultType responseType = 19 req.QueryString ["raw"] != null ? WebCommandResult.ResultType.Raw : 20 (req.QueryString ["simple"] != null ? WebCommandResult.ResultType.ResultOnly : 21 WebCommandResult.ResultType.Full); 17 22 18 23 string commandline = req.QueryString ["command"]; … … 36 41 } 37 42 38 // TODO: Execute command (store resp as IConsoleConnection instance to deliver response to the single client?)39 40 43 resp.SendChunked = true; 41 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, resp );44 WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, resp); 42 45 SdtdConsole.Instance.ExecuteAsync (commandline, wcr); 43 46 } -
binary-improvements/MapRendering/Web/API/GetAnimalsLocation.cs
r251 r306 9 9 class GetAnimalsLocation : WebAPI 10 10 { 11 private List<EntityAnimal> animals = new List<EntityAnimal> (); 12 11 13 public override void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 12 14 { 13 15 JSONArray animalsJsResult = new JSONArray(); 14 16 15 foreach (EntityAnimal entity in Animals.List) 16 { 17 Animals.Get (animals); 18 for (int i = 0; i < animals.Count; i++) 19 { 20 EntityAnimal entity = animals [i]; 17 21 Vector3i position = new Vector3i(entity.GetPosition()); 18 22 -
binary-improvements/MapRendering/Web/API/GetHostileLocation.cs
r251 r306 9 9 class GetHostileLocation : WebAPI 10 10 { 11 private List<EntityEnemy> enemies = new List<EntityEnemy> (); 12 11 13 public override void HandleRequest(HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel) 12 14 { 13 15 JSONArray hostilesJsResult = new JSONArray(); 14 16 15 foreach (EntityEnemy entity in Hostiles.List) 17 Hostiles.Get (enemies); 18 for (int i = 0; i < enemies.Count; i++) 16 19 { 20 EntityEnemy entity = enemies [i]; 17 21 Vector3i position = new Vector3i(entity.GetPosition()); 18 22 -
binary-improvements/MapRendering/Web/API/GetStats.cs
r279 r306 21 21 22 22 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count)); 23 result.Add ("hostiles", new JSONNumber (Hostiles.Count));24 result.Add ("animals", new JSONNumber (Animals.Count));23 result.Add ("hostiles", new JSONNumber (Hostiles.GetCount ())); 24 result.Add ("animals", new JSONNumber (Animals.GetCount ())); 25 25 26 26 WriteJSON (resp, result); -
binary-improvements/MapRendering/Web/API/GetWebUIUpdates.cs
r279 r306 24 24 25 25 result.Add ("players", new JSONNumber (GameManager.Instance.World.Players.Count)); 26 result.Add ("hostiles", new JSONNumber (Hostiles.Count));27 result.Add ("animals", new JSONNumber (Animals.Count));26 result.Add ("hostiles", new JSONNumber (Hostiles.GetCount ())); 27 result.Add ("animals", new JSONNumber (Animals.GetCount ())); 28 28 29 29 result.Add ("newlogs", new JSONNumber (LogBuffer.Instance.LatestLine - latestLine)); -
binary-improvements/MapRendering/Web/API/WebAPI.cs
r279 r306 7 7 public abstract class WebAPI 8 8 { 9 public void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root)9 public static void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root) 10 10 { 11 11 byte[] buf = Encoding.UTF8.GetBytes (root.ToString()); … … 14 14 resp.ContentEncoding = Encoding.UTF8; 15 15 resp.OutputStream.Write (buf, 0, buf.Length); 16 } 17 18 public static void WriteText (HttpListenerResponse _resp, string _text) 19 { 20 byte[] buf = Encoding.UTF8.GetBytes (_text); 21 _resp.ContentLength64 = buf.Length; 22 _resp.ContentType = "text/plain"; 23 _resp.ContentEncoding = Encoding.UTF8; 24 _resp.OutputStream.Write (buf, 0, buf.Length); 16 25 } 17 26
Note:
See TracChangeset
for help on using the changeset viewer.